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.
 
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.
 
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.
 
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 ;
}

最新文章

  1. ios textfield / textview长按复制粘贴中文显示
  2. AndroidStudio快捷键
  3. MVVM架构~knockoutjs系列之验证信息自定义输出~再续
  4. CF 2B.The least round way
  5. MySql批处理的小窍门:排行榜类数据生成
  6. java中的null和&quot;&quot;区别
  7. 一道有趣的javascript编程题
  8. 面向对象的异常处理之深入理解java异常处理机制
  9. App Thinning
  10. unity3d Human skin real time rendering plus 真实模拟人皮实时渲染 plus篇
  11. input在苹果浏览器下变成圆角的解决方案
  12. ubuntu下C/C++获取剩余内存
  13. Spring基于AspectJ的AOP的开发——注解
  14. 基于Jenkins实现持续集成【持续更新中】
  15. CentOS虚拟机和物理机共享文件夹实现
  16. Flask系列09--Flask中WTForms插件,及自定义验证器
  17. golang包管理的取巧
  18. 使用blessed 开发丰富的cli 应用
  19. react-native 组件的导入、导出
  20. 缓存技术内部交流_05_Cache Through

热门文章

  1. c#安全性、稳定性、高性能需要注重的点
  2. IOS之沙盒(Sandbox)机制
  3. Essential C++ 学习笔记01--基本语法
  4. Thrift 应用场景(收集版)
  5. iOS面试题6.30总结
  6. 简易ORM(基于注解)
  7. thinkphp分页格式的完全自定义,直接输入数字go到输入数字页
  8. 基于jquery实现的文字淡入淡出效果
  9. Python 学习笔记(1) - 开始
  10. 2016030208 - sql50题练习题