HDU 2085 核反应堆 --- 简单递推

HDU 2085 核反应堆

/* HDU 2085 核反应堆 --- 简单递推 */
#include <cstdio>

const int N = 35;
long long a[N], b[N]; //a表示高能质点数目,b表示低能质点数目

int main()
{
#ifdef _LOCAL
    freopen("D:\\input.txt", "r", stdin);
#endif 
    //质点数目初始化
    a[0] = 1;b[0] = 0;
    for (int i = 1; i <= 33; ++i){
        a[i] = 3 * a[i - 1] + 2 * b[i - 1];
        b[i] = a[i - 1] + b[i - 1];
    }
    int n;
    while (scanf("%d", &n) == 1 && n != -1){
        printf("%lld, %lld\n", a[n], b[n]);
    }

    return 0;
}
View Code

 

posted @ 2015-12-28 03:23  tan90丶  阅读(163)  评论(0编辑  收藏  举报