Codeforces GYM 101147D. Popcorn
传送门:http://codeforces.com/gym/101147/problem/D
题目翻译
求(C_n^m)
题解
杨辉三角形递推
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
//while(true) RP++; #include<cstdio> #include<cstring> using namespace std; const int Maxn=20; long long c[Maxn+5][Maxn+5]; inline void init(){ for (int i=1;i<=Maxn;i++){ c[i][0]=c[i][i]=1; for (int j=1;j<i;j++) c[i][j]=c[i-1][j-1]+c[i-1][j]; } } inline void solve(int T){ int n,m; scanf("%d%d",&n,&m); printf("%I64d\n",c[n][m]); } int main(){ freopen("popcorn.in","r",stdin); init(); int T=0; while(scanf("%d",&T)!=EOF) for (int i=1;i<=T;i++) solve(i); return 0; } |

原文链接:Codeforces GYM 101147D. Popcorn
WNJXYKの博客 版权所有,转载请注明出处。
还没有任何评论,你来说两句吧!