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/archive/2013/05/25/3099067.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值