ZOJ 2872 Binary Partitions
来源:互联网 发布:算法导论要学吗 编辑:程序博客网 时间:2024/05/20 21:23
Hadi loves binary numbers. So he likes to partition everything into powers of two. He wonders in how many ways he can partition a given number n into powers of two.
For example, there are 2 ways to partition 3: 1+1+1 and 1+2.
Help Him.
Input
The first line of input consists of a single integer T, the number of test-cases. Each test-case consists of a line containing n. (0 <= n <= 2,000,000)
Output
For each test-case, output a line containing number of ways in which n can be partitioned into binary numbers modulo 1,000,000.
Sample Input
4
1
2
3
280
Sample Output
1
2
2
93298
直接当做背包搞好了
#include<cstdio>#include<cmath>#include<vector>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const int maxn = 2000005;int n, f[maxn], x;int main(){ f[0] = 1; for (int j = 0; (1 << j) < maxn; j++) for (int i = (1 << j); i < maxn; i++) (f[i] += f[i - (1 << j)]) %= 1000000; while (scanf("%d", &n) != EOF) { while (n--) { scanf("%d", &x); printf("%d\n", f[x]); } } return 0;}
0 0
- ZOJ 2872 Binary Partitions
- zoj 2872 Binary Partitions(简单递推)
- Partitions
- soj 2785 Binary Partitions (构造类似完全背包)
- zoj 1383 Binary Numbers
- zoj 1712 Skew Binary
- ZOJ 1383 Binary Numbers
- ZOJ 1712 Skew Binary
- zoj 1383.Binary Numbers
- zoj 1383 Binary Numbers
- ZOJ 1383 Binary Numbers
- ZOJ 3418 Binary Number
- ZOJ 1383: Binary Numbers
- ZOJ 1383 Binary Numbers
- zoj 1383 Binary Numbers
- zoj 1383 Binary Numbers
- ZOJ 1383 Binary Numbers
- ZOJ 2054 Binary Search(模拟)
- Python编译器的选择与比较(入门必备)
- iOS--设置Launch Image 启动图片
- UIMenuController的使用,对UILabel拷贝以及定制菜单
- 面向对象学习
- SecureCRT 连接 Ubuntu
- ZOJ 2872 Binary Partitions
- Ajax乱码解决
- eclipse内存溢出错误
- strpbrk
- web 间的通信问题解决方案
- 文件,文件夹编码转换
- Sphinx语音识别学习记录 (三)-小范围语音英文识别
- 重新认识二叉树
- POJ 3274 Gold Balanced Lineup hash