UVA.12034 Race (递推)
来源:互联网 发布:淘宝店铺导航条背景色 编辑:程序博客网 时间:2024/05/18 00:13
UVA.12034 Race (递推)
题意分析
现在有
如当
考虑这样一件事情,首先要确定一下出来有多少个并列第一名,有
每种方案有
对于某一种情况,我们只是确定了第一名,没有确定其他名的情况,这样考虑。
现在剩下
不难得到最后的公式:
不要忘记边求取模。
代码总览
#include <bits/stdc++.h>#define nmax 1005#define MOD 10056using namespace std;int c[nmax][nmax];int ans[nmax];void init(){ for(int i = 0;i<nmax;++i){ c[i][0] = 1; for(int j = 1;j<=i;++j) c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD; } ans[0] = ans[1] = 1; for(int i = 2;i<nmax;++i) for(int j = 1;j<=i;++j) ans[i] = (ans[i] + (c[i][j] * ans[i-j] ) % MOD) % MOD;}int main(){ int t ,n; scanf("%d",&t); init(); for(int kase = 1;kase <=t;++kase){ scanf("%d",&n); printf("Case %d: %d\n",kase,ans[n]); } return 0;}
阅读全文
0 0
- UVA 12034 - Race(递推)
- Race - UVa 12034 递推
- uva 12034 Race递推
- UVA.12034 Race (递推)
- uva 12034 Race(递推+组合数)
- UVA 12034 Race 动态规划+递推
- 【UVA】12034-Race(递推,组合数打表)
- UVA 12034 Race (递推神马的)
- UVa 12034 - Race(组合+递推)
- 12034 - Race(递推)
- UVa12034 Race 递推
- UVa 12034 - Race
- UVA - 12034 Race
- UVA 12034 Race
- UVA 12034 Race
- UVA 12034-Race
- uva 12034 Race
- UVA 12034(p332)----Race
- 玲珑杯 Round #20
- Android插件化从入门到放弃-最强合集
- 二维凸包Haskell实现
- Expected a component class, got [object Object]
- 99. Recover Binary Search Tree
- UVA.12034 Race (递推)
- 嵌入式每日学习心得 守护进程
- 基础校验
- leetcode problem3解题报告
- java 总结几种线程异步转同步的方法
- linux学习命令 一
- VS中使用QT,多国语言翻译问题
- JAVA基础知识二
- 上Google 最简单的办法 更改hosts 见laod