Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7288 | Accepted: 3546 |
Description
Input
Output
Sample Input
2 8 12 100 200
Sample Output
3 171 2731 845100400152152934331135470251 1071292029505993517027974728227441735014801995855195223534251
Source
#include <stdio.h> struct node{ int a[1000] ; int top ; }p[300]; int main() { int n , i ; p[0].a[0] = 1 ; p[0].top = 1 ; p[1].a[0] = 1 ; p[1].top = 1 ; for(i = 2 ; i <= 250 ; i++) { int j , s = 0 , k = 0 ; for(j = 0 ; j < p[i-1].top ; j++) { s = p[i-1].a[j] + p[i-2].a[j] * 2 + k ; p[i].a[j] = s % 10 ; k = s / 10 ; } p[i].top = p[i-1].top ; if(k != 0) { p[i].a[j] = k ; p[i].top++ ; } } while(scanf("%d", &n) !=EOF) { for(i = p[n].top-1 ; i >= 0 ; i--) { printf("%d", p[n].a[i]); } printf("\n"); } return 0; }