hdu2502 月之数
来源:互联网 发布:看不见的战争 知乎 编辑:程序博客网 时间:2024/04/30 01:38
1008.月之数
题意为,求出二进制数位数为n的数的个数。由于1<=n<=20,由于数据范围很小,暴力预处理出来,然后输出答案即可。
#include<cstdio>#include<cstring>const int maxn=100;int f[maxn];int main(){ memset(f,0,sizeof(f)); int ans=0,now=0; while (ans<=20) { ans=0; int st=now,w=0; while (st>0) { ans++; if (st&1) w++; st>>=1; } if (ans>20) break; f[ans]+=w; now++; } int t; scanf("%d",&t); while (t--) { int n; scanf("%d",&n); printf("%d\n",f[n]); } return 0;}
0 0
- HDU2502:月之数
- hdu2502 月之数
- HDU2502:月之数
- hdu2502:月之数
- HDU2502 月之数
- 月之数(HDU2502)
- HDU2502 月之数【水题】【规律】
- HDU2502 月之数(解法二)
- HDU2502 月之数(解法三)
- hdu2502-月之数 注意int double范围
- hdu2502
- hdu2502&杭电oj_2502(组合数)
- 2502 月之数
- hdu 月之数
- 月之数
- HDU 月之数
- 月之数
- 月之数
- Ubuntu12.04下Tomcat集群搭建详细步骤
- dos 自定义函数
- Adaptec by PMC 联合希捷展示12Gb/s SAS及分层存储解决方案
- 微信-心跳机制
- MantisBT 时间设置
- hdu2502 月之数
- The connection to adb is down, and a severe error has occured.
- word2vec并行实现小记
- java基础三大特性——封装、继承与多态
- Aptana Studio 三 中设置 Sencha Touch 的代码提示
- 讲座:与迷茫为友的成长(贺利坚老师,烟台大学)——完整讲座PPT,精彩与动画媲美
- 又是一年木棉红
- 动态规划解决skiing问题
- java Calendar和Date()的转化