首页 > 其他 > 详细

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

时间:2015-12-28 06:15:46      阅读:197      评论:0      收藏:0      [点我收藏+]

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

 

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

原文:http://www.cnblogs.com/tommychok/p/5081373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!