标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7547 Accepted Submission(s): 4020
1 #include<stdio.h> 2 #define LL __int64 3 LL num[36][36]={0}; 4 void init() 5 { 6 for(int i=1;i<=35;i++) 7 { 8 num[i][0]=1; 9 for(int j=1;j<i;j++) 10 num[i][j]=num[i][j-1]+num[i-1][j]; 11 num[i][i]=num[i][i-1]; 12 } 13 } 14 int main() 15 { 16 int n,ca=1; 17 init(); 18 while(scanf("%d",&n)!=EOF) 19 { 20 if(n==-1) break; 21 printf("%d %d %I64d\n",ca++,n,2*num[n][n]); 22 } 23 return 0; 24 25 }
附以前的代码
#include <stdio.h> int main() { int i,j; __int64 a[36] = {1}; __int64 b[36] = {0}; for (i=1;i<36;i++) { for(j=1;j<i;j++) a[j]=a[j]+a[j-1]; b[i]=a[i]=a[i-1]; } for(j=1;scanf("%d",&i),i;j++) { if(i==-1) break; else printf("%d %d %I64d\n",j,i,2*b[i]); } return 0; }
发现现在做以前的题,想到的思路有些不同。。。
标签:
原文地址:http://www.cnblogs.com/yuyixingkong/p/4648012.html