/*  比赛的名次的所有方案数 _________________________________________________________________________________

                                           #include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define fir first
#define sec second
#define pb(x) push_back(x)
#define mem(A, X) memset(A, X, sizeof A)
#define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))
#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;
typedef unsigned long long ull;
typedef pair<long,long> pll; LL T,n;
const LL mod=10056;
LL f[1000+10]; LL c[1005][1005];
const int maxn=1001;
const int MOD=10056;
void init() {
for(int i = 0; i <= maxn; i++) {
c[i][0] = c[i][i] = 1;
for(int j = 1; j < i; j++)
c[i][j] = (c[i-1][j] + c[i-1][j-1]) % MOD;
}
} int main()
{
freopen("in.txt","r",stdin); init();
mem(f,0); f[0]=1;
REP(n,1,1000)
REP(i,1,n) f[n]+=c[n][i]*f[n-i]%mod;
while(cin>>T)
{
REP(kase,1,T)
{
int n;
cin>>n;
cout<<"Case "<<kase<<": "<<f[n]%mod<<endl;
} }
return 0;
} /*
note : 运用子问题寻找递推关系。
debug : 组合数初始化的时候,牵扯到取模的时候不能用横向的递推关系,会导致出现0,
optimize:
*/

uva 12034的更多相关文章

  1. UVa 12034 - Race(递推 + 杨辉三角)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. UVa 12034 (递推) Race

    题意: 有n个人赛马,名次可能并列,求一共有多少种可能. 分析: 设所求为f(n),假设并列第一名有i个人,则共有C(n, i)种可能,接下来确定后面的名次,共有f(n-1)种可能 所以递推关系为: ...

  3. UVa 12034 Race (递推+组合数学)

    题意:A,B两个人比赛,名次有三种情况(并列第一,AB,BA).输入n,求n个人比赛时最后名次的可能数. 析:本来以为是数学题,排列组合,后来怎么想也不对.原来这是一个递推... 设n个人时答案为f( ...

  4. UVa 12034 比赛名次(递推)

    https://vjudge.net/problem/UVA-12034 题意: A.B两人赛马,最终名次有3种可能:并列第一:A第一B第二:B第一A第二.输入n,求n人赛马时最终名次的可能性的个数除 ...

  5. Race UVA - 12034(dp+打表)

    Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded ...

  6. UVA 12034 Race

    https://vjudge.net/problem/UVA-12034 题意:n个人比赛,有多少种可能的结果 假设i个人中,有j个人是第一名,方案数为C(i,j) 所以ans=Σ C(n,j)* f ...

  7. UVA 12034 Race (递推神马的)

    Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded ...

  8. UVA 12034 Race(递推)

    递推,f[i = i个名次][j = 共有j个人] = 方案数. 对于新加入的第j个人,如果并列之前的某个名次,那么i不变,有i个可供并列的名次选择,这部分是f[i][j-1]*i, 如果增加了一个名 ...

  9. 紫书 例题 10-14 UVa 12034(组合数+递推)

    这道题有点类似动态规划,设答案为f(n) 第一个人有i个人,就有c(n,i)种可能 然后后面有f(n-i)种可能,所以相乘,然后枚举所有可能加起来就ok了. #include<cstdio> ...

随机推荐

  1. eclipse 导入工程报错Unable to execute dex: Multiple dex files define Landroid/annotation/SuppressLint

    对策: 检查libs 是否有重复加载的.

  2. The guard was taken to hospital in a critical condition.

    The Prince George's County Fire Department said the guard was taken to hospital in a critical condit ...

  3. Python开发入门与实战18-Windows Azure 虚拟机部署

    18. 微软云虚拟机部署 上一章节我们介绍了如何在新浪云部署我们的在python django应用,本章我们来介绍如何Windows Azure上部署我们的应用. 18.1. 注册Windows Az ...

  4. 开源一个网络图片浏览器HooPhotoBrowser

    在公司开发项目中需要弹出展示从网络上下载的图片,并提供滑动展示功能.目前采用同事开发的图片浏览器,后期有时间想优化一下.所以重温了下以前开发的类似微博的项目中的图片浏览器代码,并抽取出来封装成了现在这 ...

  5. eclipse创建maven管理Spark的scala

    说明,由于spark是用scala写的.因此,不管是在看源码还是在写spark有关的代码的时候,都最好是用scala.那么作为一个程序员首先是必须要把手中的宝剑给磨砺了.那就是创建好编写scala的代 ...

  6. Your build settings specify a provisioning profile with the UUID, no provisioning profile

    在Archive项目时,出现了“Your build settings specify a provisioning profile with the UUID “”, however, no suc ...

  7. jQuery外部框架浅析

    (function(window, undefined) {         var jQuery = ...         ...             window.jQuery = wind ...

  8. LVM逻辑卷的创建及使用

    在上一篇随笔里面 LVM逻辑卷基本概念及LVM的工作原理,详细的讲解了Linux的动态磁盘管理LVM逻辑卷的基本概念以及LVM的工作原理,包括LVM中最重要的四个基本点(PE.PV.VG以及LV),这 ...

  9. Sunny-Code Beta版总结会议

    时间:2015-6-12 地点:基教601 参会人员:Sunny-Code全体成员 设想和目标 我们的软件要解决什么问题?是否定义得很清楚? 我们打算做一款集成小蝴蝶功能.Ip快速修改功能.WiFi共 ...

  10. redis DB操作

    数据库操作 1)  REDIS是全部由KEY和VALUE值构成,对数据库的增删改查操作都是基于在通过key 映射到哈希槽 然后通过哈希槽进行单向链式遍历 查找到value和具体的key. 同样 在查看 ...