Spoon Devil Love Arithmetic
来源:互联网 发布:云南广电网络oa 编辑:程序博客网 时间:2024/04/19 11:42
Spoon Devil Love Arithmetic
Time Limit:1s Memory Limit:32MByte
Submissions:66Solved:19
DESCRIPTION
Spoon Devil want to use some integers which are power of 2 to sum to a number NN. But he find that there are many possible representations.For example, given 7 as NN:7 = 1+1+1+1+1+1+17 = 1+1+1+1+1+27 = 1+1+1+2+27 = 1+1+1+47 = 1+2+2+27 = 1+2+4Please tell Spoon Devil how many possible representations there are for a given number N (1≤N≤1,000,000)N (1≤N≤1,000,000).
INPUT
The first line is a single integer TT which is the number of test cases.And for each test case, only a integer NN.
OUTPUT
For each test case, output a line with the answer mod 1000000000.
SAMPLE INPUT
17
SAMPLE OUTPUT
6
动态规划,奇数时a[i]等于a[i-1]的次数和a[i/2]乘于2的次数和
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const int N = 1001111;int a[N];const int mod=1000000000;int main(){ memset(a,0,sizeof(a)); a[1]=1,a[2]=2,a[3]=2,a[4]=4,a[5]=4; for(int i=6;i<=N;i++) { if(i%2==0) { a[i]=(a[i-1]+a[i/2])%mod; } else { a[i]=a[i-1]; } } int n, t; scanf("%d", &t); while(t--) { scanf("%d",&n); printf("%d\n",a[n]%mod); } return 0;}
0 0
- Spoon Devil Love Arithmetic
- 玲珑杯1006 Spoon Devil Love Arithmetic
- 玲珑杯 1008 Spoon Devil Love Arithmetic Again
- 玲珑杯 1007 Spoon Devil Love Game
- 玲珑学院OJ 1000 Spoon Devil's 3-D Matrix
- 玲珑杯 1003 Spoon Devil's Diamond Mine
- 玲珑杯 1005 Spoon Devil's RP Test(水题)
- 玲珑杯 1009 Spoon Devil's Bucket 矩阵优化DP
- Lonlife 1000 - Spoon Devil's 3-D Matrix
- 玲珑学院OJ 1000 - Spoon Devil's 3-D Matrix(3维最小生成树)
- 玲珑学院OJ 1005 - Spoon Devil's RP Test(求余问题)
- Lonlife-ACM 1000 - Spoon Devil's 3-D Matrix(最小生成树)——“玲珑杯”acm比赛-试运行赛
- Lonlife-ACM 1005 - Spoon Devil's RP Test(同余定理)——“玲珑杯”acm比赛-试运行赛
- spoon实战
- kettle spoon
- Kettle Spoon
- OpenIL(DevIL)
- OpenIL(DevIL)
- Git用户手册--Git 内部原理
- 经典排序算法3:堆排序
- java-并发-ConcurrentHashMap高并发机制-jdk1.8
- 实现QQ空间中显示照片效果
- Android Retrofit使用(一)
- Spoon Devil Love Arithmetic
- C++基础:文件与对象
- HDU - 5319 Painter
- POJ1328-Radar Installation(贪心)
- POJ 1860 Currency Exchange
- HDU 1598 find the most comfortable road
- 对最小二乘法的概率解释.
- C++重载函数的实现小结(实战篇)
- AQS源码分析