HDU-1339 A Simple Task
2024-10-19 19:37:36
http://acm.hdu.edu.cn/showproblem.php?pid=1339
正常做法超时,要有点小技巧存在。
A Simple Task
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3372 Accepted Submission(s): 1837
Problem Description
Given a positive integer n and the odd integer o and the nonnegative integer p such that n = o2^p.
Example
For n = 24, o = 3 and p = 3.
Task
Write a program which for each data set:
reads a positive integer n,
computes the odd integer o and the nonnegative integer p such that n = o2^p,
writes the result.
Example
For n = 24, o = 3 and p = 3.
Task
Write a program which for each data set:
reads a positive integer n,
computes the odd integer o and the nonnegative integer p such that n = o2^p,
writes the result.
Input
The first line of the input contains exactly one positive integer d equal to the number of data sets, 1 <= d <= 10. The data sets follow.
Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
Output
The output should consists of exactly d lines, one line for each data set.
Line i, 1 <= i <= d, corresponds to the i-th
input and should contain two integers o and p separated by a single space such
that n = o2^p.
Line i, 1 <= i <= d, corresponds to the i-th
input and should contain two integers o and p separated by a single space such
that n = o2^p.
Sample Input
1
24
Sample Output
3 3
Source
Recommend
Ignatius.L
#include<stdio.h>
int main()
{
long int d,k,n;
scanf("%ld",&d);
while(d--)
{
scanf("%ld",&n);
k=;
while(n%==)
{ k++;
n=n/;
}
printf("%ld %ld\n",n,k);
}
return ;
}
最新文章
- ios textfield / textview长按复制粘贴中文显示
- AndroidStudio快捷键
- MVVM架构~knockoutjs系列之验证信息自定义输出~再续
- CF 2B.The least round way
- MySql批处理的小窍门:排行榜类数据生成
- java中的null和";";区别
- 一道有趣的javascript编程题
- 面向对象的异常处理之深入理解java异常处理机制
- App Thinning
- unity3d Human skin real time rendering plus 真实模拟人皮实时渲染 plus篇
- input在苹果浏览器下变成圆角的解决方案
- ubuntu下C/C++获取剩余内存
- Spring基于AspectJ的AOP的开发——注解
- 基于Jenkins实现持续集成【持续更新中】
- CentOS虚拟机和物理机共享文件夹实现
- Flask系列09--Flask中WTForms插件,及自定义验证器
- golang包管理的取巧
- 使用blessed 开发丰富的cli 应用
- react-native 组件的导入、导出
- 缓存技术内部交流_05_Cache Through