lightoj 1173 - The Vindictive Coach 计数类DP
来源:互联网 发布:软件著作权许可使用 编辑:程序博客网 时间:2024/06/08 02:46
给定n个人,排成一个波浪形的队伍,n个人按个头高低已经编好号了。有个队长编号为m,队长是必须在最前面的,如果m=1..就不用管,否则队长后面那个要比他低...
读题坑,公式写了半天没推出来看了别人博客恍然大悟。
附上连接:点击打开链接
#include<bits/stdc++.h>using namespace std;#define ll long long#define ull unsigned long long#define mod 100000007#define inf 0x3f3f3f3full dp[55][55][2];void db(){ dp[1][1][0]=dp[1][1][1]=1; for(int i=2;i<=50;i++) { for(int j=1;j<=i;j++) { for(int k=1;k<i;k++) { if(k<j) dp[i][j][1]+=dp[i-1][k][0]; else dp[i][j][0]+=dp[i-1][k][1]; } } }}int main(){ int t; db(); scanf("%d",&t); for(int cas=1;cas<=t;cas++) { int n,m; scanf("%d %d",&n,&m); ull ans=0; if(m==1) { if(n<=2) ans=1; else ans=dp[n-1][2][1]; } else { for(int i=1;i<=m-1;i++) ans+=dp[n-1][i][0]; } printf("Case %d: %llu\n",cas,ans); } 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 1122【计数DP】
- lightoj 1231 1232 1233 DP 背包计数
- LightOJ 1231 Coin Change (I) (线性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)
- HDU4901 The Romantic Hero 计数DP
- 详解网络传输中的三张表,MAC地址表、ARP缓存表以及路由表
- 20160330 HDU5651 xiaoxin juju needs help(组合数公式)
- 重新安装包
- sql中的group by 和 having 用法解析
- CodeForces 639B Bear and Forgotten Tree 3(水题)
- lightoj 1173 - The Vindictive Coach 计数类DP
- quartz的两个点
- 浅析java反射机制
- sata硬盘
- sleep wait区别
- Selenium源码学习
- 蓝桥杯_算法提高_新建MicrosoftWord文档
- bzoj 2821: 作诗(Poetize)
- Adb connection Error:远程主机强迫关闭了一个现有的连接