LightOJ 1173 The Vindictive Coach (DP)
来源:互联网 发布:知乎离线下载 编辑:程序博客网 时间:2024/06/05 12:49
解析:关于题意的理解参考:点击打开链接
设dp[i][j] 为考虑前i个位置且高度小于第i个位置的人数为j的方案数。
状态转移方程:
dp[i][j] = i&1? sigma(dp[i-1][j-k]):sigma(dp[i-1][j+k])
[code]:
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef unsigned long long LL;int n,m;LL dp[55][55];int main(){ int i,j,k,cas; scanf("%d",&cas); for(int T=1;T<=cas;T++){ scanf("%d%d",&n,&m); memset(dp,0,sizeof(dp)); printf("Case %d: ",T); if(m==1&&n<=4){ puts("1"); }else{ if(m==1) n--,m=2; dp[1][m-1] = 1; for(i = 2;i <= n;i++){ for(j = 0;j <= n-i;j++){ dp[i][j] = 0; if(i&1){ for(k = 0;k <= j&&j-k<=n-i+1;k++) dp[i][j] += dp[i-1][j-k]; }else{ for(k = 1;k <= n-j&&j+k<=n-i+1;k++) dp[i][j] += dp[i-1][j+k]; } } } printf("%llu\n",dp[n][0]); } } return 0;}
0 0
- LightOJ 1173 The Vindictive Coach (DP 计数)
- LightOJ 1173 The Vindictive Coach (DP)
- lightoj 1173 - The Vindictive Coach 计数类DP
- LightOJ 1173 The Vindictive Coach(DP计数)
- uva 702 The Vindictive Coach (DP)
- lightoj 1025 The Specials Menu (DP)
- LightOJ 1025 - The Specials Menu(dp)
- LightOJ 1025 - The Specials Menu(区间DP)
- LightOJ 1025 - The Specials Menu【区间DP】
- lightoj 1025-The Specials Menu 区间DP
- lightoj 1025 - The Specials Menu 【区间dp】
- LightOJ-1274 Beating the Dataset(期望dp)
- [区间DP] The Specials Menu LightOJ
- lightoj 1025 The Specials Menu (dp)
- LightOJ - 1025 The Specials Menu(区间DP)
- LightOJ 1025 - The Specials Menu (区间dp)
- [LightOJ 1274] Beating the Dataset (期望DP)
- 【概率DP】 LightOJ 1342 Aladdin and the Magical Sticks
- 二维数组中的查找
- HIVE 新特性 ACID 初试
- mongodb的安装详解
- 记录几次产品面试和笔试总结
- Spring中的事务管理
- LightOJ 1173 The Vindictive Coach (DP)
- Hibernate入门
- Leetcode 146. LRU Cache
- BestCoder Round #78 (div.1) CA Loves GCD
- SDAU课程练习2 1023
- 欢迎使用CSDN-markdown编辑器
- 每天laravel-20160627|TaggableStore
- 翻译了一下Unity新的UI的画布渲染模式,记录一下,希望有人能用得上。
- python 安装第三方插件