UVA12034 Race【排列】
Disky and Sooma,two of the biggest mega minds of Bangladesh went to a far country. They ate,coded and wandered around,even in their holidays. They passed several months in this way. But everything has an end. A holy person,Munsiji came into their life. Munsiji took them to derby (horse racing). Munsiji enjoyed the race,but as usual Disky and Sooma did their as usual task instead of passing some romantic moments. They were thinking- in how many ways a race can finish! Who knows,maybe this is their romance!
Input 问题链接:UVA12034 Race AC的C语言程序如下: /* UVA12034 Race */ #include <stdio.h> #include <string.h> #define N 1000 #define MOD 10056 int dp[N + 1][N + 1],ans[N + 1]; void init_table() { int i,j; memset(dp,sizeof(dp)); memset(ans,sizeof(ans)); for(i = 1; i <= N; i++) { dp[i][1] = 1; for(j = 2; j <= i; j++) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) * j % MOD; for(j = 1; j <= i; j++) ans[i] = (ans[i] + dp[i][j]) % MOD; } } int main(void) { init_table(); int t,n,i; scanf("%d",&t); for(i = 1; i <= t; i++) { scanf("%d",&n); printf("Case %d: %dn",i,ans[n]); } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |