Binomial Coeffcients(山东省第二届省赛G题)

http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2164&cid=1173

这个题不用大数,其使用杨辉三角就可以

百度上搜杨辉三角有一个关于阶乘的性质

 1 #include<stdio.h>
 2 #include<string.h>
 3 #define MAXN 1010
 4 int  ch[MAXN][MAXN] ;
 5 int main()
 6 {
 7     int n ;
 8     ch[0][0] = 1 ;
 9     ch[0][1] = 0 ;
10     ch[1][0] = 1;
11     for(int i = 1 ; i < MAXN ; i++)
12     {
13         ch[i][0] = 1 ;
14         for(int j = 1 ; j < i ; j++)
15         {
16             ch[i][j] = ch[i-1][j]+ch[i-1][j-1] ;
17             if(ch[i][j] >= 10000003)
18                 ch[i][j] -= 10000003 ;
19         }
20         ch[i][i] = 1 ;
21     }
22     scanf("%d",&n);
23     int x,y ;
24     for(int i = 1 ; i <= n ; i++)
25     {
26         scanf("%d %d",&x,&y) ;
27         printf("%d\n",ch[x][y]) ;
28     }
29     return 0 ;
30 }
View Code
原文地址:https://www.cnblogs.com/luyingfeng/p/3099067.html