[PKU 2229] Sumsets (计数DP+构造)
来源:互联网 发布:思科mac地址 编辑:程序博客网 时间:2024/06/08 19:40
PKU - 2229
将一个数分为若干个 2的次幂之和,问有几种方案
当 i为奇数时:
当 i为偶数时:
最后答案为
#pragma comment(linker, "/STACK:102400000,102400000")#include <cstdio>#include <iostream>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>#include <map>#include <set>#include <queue>using namespace std;typedef pair<int,int> Pii;typedef long long LL;typedef unsigned long long ULL;typedef double DBL;typedef long double LDBL;#define MST(a,b) memset(a,b,sizeof(a))#define CLR(a) MST(a,0)#define Sqr(a) ((a)*(a))const LL MOD=1e9;const int maxn=1e6+10;int N;LL dp[maxn][3];int main(){ #ifdef LOCAL freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout); #endif while(~scanf("%d", &N)) { CLR(dp); dp[1][0]=0; dp[1][1] = dp[1][2] = 1; for(int i=2; i<=N; i++) { if(i&1) { dp[i][0] = 0; dp[i][1] = dp[i-1][0]; dp[i][2] = dp[i-1][0]+dp[i-1][2]; } else { dp[i][0] = dp[i/2][0]+dp[i/2][2]; dp[i][1] = 0; dp[i][2] = dp[i-1][0]+dp[i-1][2]; } dp[i][0]%=MOD; dp[i][1]%=MOD; dp[i][2]%=MOD; } printf("%lld\n", (dp[N][0]+dp[N][2])%MOD); } return 0;}
0 0
- [PKU 2229] Sumsets (计数DP+构造)
- POJ 2229 Sumsets(DP计数问题)
- POJ 2229 Sumsets(计数dp)
- poj 2229 Sumsets (DP)
- POJ 2229-Sumsets(DP)
- POJ 2229 Sumsets (dp)
- POJ 2229 Sumsets(dp)
- POJ 2229 Sumsets (简单DP)
- Sumsets (poj 2229 简单dp)
- POJ 2229 Sumsets(dp 递推)
- POJ 2229 Sumsets(数位DP)
- POJ-2229-Sumsets -(简单dp)
- POJ 2229 Sumsets(基础dp)
- poj 2229 Sumsets DP
- POJ 2229 Sumsets DP
- POJ-2229 Sumsets DP
- poj 2229 Sumsets【DP】
- Poj 2229 Sumsets【dp】
- Mp4box的下载、安装和使用
- android:uiOptions="splitActionBarWhenNarrow"
- hadoop安装02
- 5月底小结
- EditText常用属性
- [PKU 2229] Sumsets (计数DP+构造)
- Ubuntu 14.04 学习笔记
- 第三讲-------Logistic Regression & Regularization
- redis的持久化(RDB和AOF方式)
- eclipse+jetty+Maven
- typedef函数指针用法
- Shell数组
- Middle-题目86:207. Course Schedule
- java 常用排序算法