标签:des style blog http io color ar os sp
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7755 | Accepted: 3770 |
Description
Input
Output
Sample Input
2 8 12 100 200
Sample Output
3 171 2731 845100400152152934331135470251 1071292029505993517027974728227441735014801995855195223534251
Source
#include <stdio.h> #include <string.h> int a[310][310]; int main() { int n, i, j, s, k, p; while (scanf("%d", &n) != EOF) { memset(a, 0, sizeof(a)); a[0][0] = 1;//初始化 a[1][0] = 1; a[2][0] = 3; if (n <= 2) { printf("%d\n", a[n][0]); } else { s = 1; for (i = 3; i <= n; ++i) { k = 0; //记录是否超过十 p = 0; for (j = 0; j < s; ++j) { p = a[i - 2][j] * 2 + a[i - 1][j] + k; a[i][j] = p % 10; k = p / 10; } if (k)//位数增加一位时的处理 { a[i][s] = k; s ++; } } for (i = s - 1; i >= 0; --i) { printf("%d", a[n][i]); } printf("\n"); } } return 0; }
标签:des style blog http io color ar os sp
原文地址:http://www.cnblogs.com/ikids/p/4087992.html