标签:des style class blog c code
先上题目:
Time Limit: 10000/5000 MS
(Java/Others) Memory Limit: 65535/65535 K
(Java/Others)
Total Submission(s): 0 Accepted
Submission(s): 0
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define MAX 1000003 5 #define MOD 1000000007 6 #define LL long long 7 using namespace std; 8 9 LL s[MAX]; 10 11 LL exgcd(LL a,LL b,LL &x,LL &y){ 12 if(b==0){ 13 x=1; y=0; return a; 14 } 15 LL d = exgcd(b,a%b,x,y); 16 LL t=x;x=y;y=t-a/b*y; 17 return d; 18 } 19 20 void deal(){ 21 s[1]=s[2]=1; 22 int n = MAX; 23 LL x,y; 24 for(int i=2;i<=n;i++){ 25 s[i+1]=(4*i-6)%MOD; 26 s[i+1]=(s[i+1]*s[i])%MOD; 27 exgcd(i,MOD,x,y); 28 s[i+1]=(s[i+1]*((x+MOD)%MOD))%MOD; 29 } 30 } 31 32 int main() 33 { 34 int t,n; 35 //freopen("data.txt","r",stdin); 36 deal(); 37 scanf("%d",&t); 38 for(int z=1;z<=t;z++){ 39 scanf("%d",&n); 40 printf("Case #%d:\n",z); 41 printf("%I64d\n",s[n+2]); 42 } 43 return 0; 44 }
百度之星2014初赛 - 1002 - Grids,布布扣,bubuko.com
标签:des style class blog c code
原文地址:http://www.cnblogs.com/sineatos/p/3750351.html