Time Limit:
1000MS
|
|
Memory Limit:
30000K
|
Total Submissions:
8331
|
|
Accepted:
4141
|
Description
Input
Output
Sample Input
2 3 -1
Sample Output
2
#include<stdio.h> #include<stdlib.h> #include<string.h> int max=100; void mul(int a[],int b) {///大数乘法 int i,jinwei=0;///进位 for(i=max-1;i>=0;i--) { jinwei+=b*a[i]; a[i]=jinwei%10000; jinwei/=10000; } } void div(int a[],int b) {///大数除法 int i,jiewei=0;///借位 for(i=0;i<max;i++) { jiewei=jiewei*10000+a[i]; a[i]=jiewei/b; jiewei%=b; } } int main() { int n; int i,j; int a[101][101]; for(i=0;i<101;i++) for(j=0;j<101;j++) a[i][j]=0; ///初始化a[1]=1; for(i=0;i<max-1;i++) a[1][i]=0; a[1][max-1]=1; for(i=2;i<=100;i++) { memcpy(a[i],a[i-1],max*sizeof(int)); //将a[i-1]拷贝到a[i] mul(a[i],4*i-2); div(a[i],i+1); } while(scanf("%d",&n)) { if(n==-1) break; for(i=0;i<max&&a[n][i]==0;i++); printf("%d",a[n][i++]); ///输出首位 for(;i<max;i++) { printf("%04d",a[n][i]);///输出剩下的位数,数组中不足4位的在前边补0 } printf("\n"); } return 0; }