Codeforces Round #247 (Div. 2) C k-Tree
来源:互联网 发布:java lambda this 编辑:程序博客网 时间:2024/06/08 05:23
dp[i][j][0]//第i层和为j不满足条件的个数
dp[i][j][1]//第i层和为j满足条件个数
#include<iostream>#include<sstream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<stack>#include<math.h>#include<map>#include<time.h>#include<set>#include<string>#include<vector>#include<algorithm>using namespace std;#define inf 0x7fffffff#define lc l,m,index<<1#define rc m+1,r,index<<1|1#define max_n 200005#define mod 1000000007#define LL __int64LL dp[105][105][2];int n,k,d;int main(){ while(~scanf("%d%d%d",&n,&k,&d)) { memset(dp,0,sizeof(dp)); for(int i=1;i<=k;i++) { if(i<d) dp[1][i][0]=1; else dp[1][i][1]=1; } for(int i=2;i<=n+1;i++) { for(int j=i;j<=n;j++) { for(int x=1;x<=k;x++) { if(x>=j)continue; if(x<d) { dp[i][j][0]=(dp[i][j][0]+dp[i-1][j-x][0])%mod; dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-x][1])%mod; } else dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-x][0]+dp[i-1][j-x][1])%mod; // printf("i == %d j == %d x == %d ans == %d\n",i,j,x,dp[i][j][1]); // system("pause"); } } } LL ans=0; /* for(int i=1;i<=n;i++) { for(int j=i;j<=n;j++) { printf("dp[%d][%d][1] == %d\n",i,j,dp[i][j][1]); printf("dp[%d][%d][0] == %d\n",i,j,dp[i][j][0]); } } */ for(int i=1;i<=n+1;i++) { // printf("i == %d ans == %d\n",i,dp[i][n][1]); ans=(ans+dp[i][n][1])%mod; } printf("%I64d\n",ans); } return 0;}
0 0
- Codeforces Round #247 (Div. 2) C. k-Tree
- Codeforces Round #247 (Div. 2) C.K-Tree
- Codeforces Round #247 (Div. 2) C k-Tree
- Codeforces Round #247(Div. 2) C. k-Tree DP
- Codeforces #247 (Div. 2) C. k-Tree
- Codeforces Round #247 (Div. 2)a.Black Square,b.Shower Line,c.k-Tree前三题
- Codeforces Round #342 (Div. 2)--C. K-special Tables
- Codeforces Round #358 (Div. 2) C. Alyona and the Tree
- Codeforces Round #358 (Div. 2)C. Alyona and the Tree
- Codeforces Round #358 (Div. 2) C. Alyona and the Tree
- Codeforces Round #369 (Div. 2) 711C Coloring Tree (DP)
- Codeforces Round #245 (Div. 2)-C. Xor-tree
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- Codeforces Round #245 (Div. 2) C. Xor-tree DFS
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree
- Codeforces Round #232 (Div. 1) C. On Changing Tree(树上修改一点x-di*k))
- Android单点触控技术,对图片进行平移,缩放,旋转操作
- FIR.im 帮你生成管理邀请码 -- inCode
- paoding、imdict、mmseg4j、ik四种分词器的比较
- Openstack并行性能加速(转)
- HashMap源码阅读(2)- 碰撞(冲突)与扩容
- Codeforces Round #247 (Div. 2) C k-Tree
- Java中Math类的几个四舍五入方法的区别
- centos 安装软件
- Thinking in java -- set和存储顺序
- SQLite支持的数据类型
- 深入理解Java内存模型
- 【数据结构】链表
- RFID作业2-3
- Oracle创建自增字段方法-ORACLE SEQUENCE的简单介绍