标签:des style blog io os java for sp div
戴帽子的
#include<stdio.h> #include<string.h> int f1[2050],f2[2050],f3[2050],f4[2050],f5[2050]; int main() { int N; while(~scanf("%d",&N)) { if(N==1) printf("1\n"); else if(N==2) printf("1\n"); else if(N==3) printf("1\n"); else if(N==4) printf("1\n"); else { memset(f1,0,sizeof(f1)); memset(f2,0,sizeof(f2)); memset(f3,0,sizeof(f3)); memset(f4,0,sizeof(f4)); memset(f5,0,sizeof(f5)); f1[0] = f2[0] = f3[0] = f4[0] = 1; for(int i = 5; i<= N; i++) { for(int j = 0; j <= 2010; j++) { f5[j] = f1[j] + f2[j] + f3[j] + f4[j]; if(f5[j] >= 10) { f1[j+1] += (f5[j]/10); f5[j] = (f5[j]%10); } f1[j] = f2[j]; f2[j] = f3[j]; f3[j] = f4[j]; f4[j] = f5[j]; } } int j; for(j = 2010; j >= 0; j--) if(f5[j]!=0) break; for(int i = j; i >= 0; i--) printf("%d",f5[i]); printf("\n"); } } return 0; }
HDU1250_Hat's Fibonacci【大数】【水题】
标签:des style blog io os java for sp div
原文地址:http://blog.csdn.net/lianai911/article/details/40297537