LightOJ 1173 The Vindictive Coach(DP计数)
来源:互联网 发布:mac怎么创建快捷方式 编辑:程序博客网 时间:2024/06/13 08:49
【题目链接】http://https://cn.vjudge.net/contest/173608#problem/B
说实话这个题我不是很懂,这也是赛后琢磨的,想看详解的童鞋点这里。
【AC代码】
#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;typedef long long unsigned ll;const int N=52;ll f[N][N],g[N][N];int m,n;void Init(){ f[1][1]=1; g[1][1]=1; for(int i=2;i<=50;++i) for(int j=1;j<=i;++j) { for(int k=j;k<=i-1;++k) f[i][j]+=g[i-1][k]; for(int k=1;k<j;++k) g[i][j]+=f[i-1][k]; } return ;}ll dp(){ ll ans=0; if(n>1) { for(int i=1;i<=n-1;++i) ans+=f[m-1][i]; } else { if(m<=2) ans=1; else ans=g[m-1][2]; } return ans;}int main(){ Init(); int t,cnt=0; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n); printf("Case %d: %llu\n",++cnt,dp()); } return 0;}
阅读全文
1 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 1025 - The Specials Menu(dp)
- lightoj 1231 1232 1233 DP 背包计数
- LightOJ 1005 - Rooks(计数)
- LightOJ - 1025 The Specials Menu(区间DP)
- LightOJ 1025 - The Specials Menu (区间dp)
- [LightOJ 1274] Beating the Dataset (期望DP)
- 【LightOJ 1274】Beating the Dataset(概率DP)
- LightOJ 1025 The Specials Menu(区间dp)
- UVALive 5002/ lightoj 1382 The Queue(树形DP)
- LightOJ 1274 Beating the Dataset (概率dp)
- hdu 4901 The Romantic Hero(计数dp)
- LightOJ 1231 Coin Change (I) (线性dp 背包计数)
- python将dateframe数据存入mysql
- 常见的后台产品及其特点详解
- ubuntu14.04下搭建lnmp开发环境及常见问题
- easyui自定义日期组件并扩展到datagrid(editor)
- Hibernate一级缓存管理-evict和clear的用法
- LightOJ 1173 The Vindictive Coach(DP计数)
- 8月10日相约阿里云数据库MySQL金融版线上发布会!
- YII2学习
- 云架构下的性能分析两实例
- POJ 3626 Mud Puddles(bfs)
- Linux(debian)网络配置
- jQuery与js绑定事件的几种写法(以单击事件示例)
- ViewPager fragment android tab选项卡的使用
- 31.Next Permutation 下一个排列