2568:前进
2015-09-18 15:53
134 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2568
方法:模拟过程
思路:大水题,不过挺有意思,重点在于模拟题目所叙述的过程,因为所给的数据量不大,可以用这种方法。
难点:无
方法:模拟过程
思路:大水题,不过挺有意思,重点在于模拟题目所叙述的过程,因为所给的数据量不大,可以用这种方法。
难点:无
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { while(n--) { int x; int num = 0; cin>>x; while(x != 0) { if(x%2 == 1) { x -= 1; num++; } if(x%2 == 0) x /= 2; } cout<<num<<endl; } } }
相关文章推荐
- Servlet-模块化开发web fragment
- android图像图像处理——自定义组件的属性
- struts2的Action该方法不能去
- 装箱拆箱
- set集合_定长
- 最常见的读入数据方法集锦
- Canny边缘检测原理
- c/c++复习日记 1.不带缓存的I/O和标准I/O
- 代码洁癖症的表现
- IE6 CSS Fixed 固定位置 防闪屏
- 集成项目经理在工作中的常见改进点
- Servlet-监听器Listener
- 笔记05 局部类型
- set集合_变长
- NSString
- 关于高德等集成的打包keystore与联调keystore
- inception安装步骤---自己整理的安装步骤
- 程序员转型产品经理真的明智吗?
- unity3d 在UGUI中制作自适应调整大小的滚动布局控件
- hdu 1026 Ignatius and the Princess I bfs 优先队列 路径记录