标签:os io for sp on c amp ios r
//a[n]=a[n-1]+a[n-2]+a[n-3]+a[n-4]; # include <stdio.h> # include <algorithm> # include <string.h> # include <iostream> using namespace std; int a[10000][260]={0}; //每个元素可以存储8位数字,所以2005位可以用260个数组元素存储。 int main() { int i,j,n; a[1][0]=1; a[2][0]=1; a[3][0]=1; a[4][0]=1; for(i=5;i<10000;i++) { for(j=0;j<260;j++) a[i][j]+=a[i-1][j]+a[i-2][j]+a[i-3][j]+a[i-4][j]; for(j=0;j<260;j++) { if(a[i][j]>100000000) { a[i][j+1]+=a[i][j]/100000000; a[i][j]=a[i][j]%100000000; } } } while(~scanf("%d",&n)) { for(j=259;j>=0;j--) if(a[n][j]) break; printf("%d",a[n][j]);// for(j=j-1;j>=0;j--) printf("%08d",a[n][j]); printf("\n"); } return 0; }
hdu 1250 Hat's Fibonacci (大数相加)
标签:os io for sp on c amp ios r
原文地址:http://blog.csdn.net/lp_opai/article/details/39155943