【杭电100题】2085 核反应堆

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2085

#include <iostream>

using namespace std;

int main()
{
    long long int high[34];
    long long int low[34];
    high[0]=1;
    low[0]=0;

    for(int i=1; i<34; i++)
    {
        high[i]=3*high[i-1] + 2*low[i-1];
        low[i]=1*high[i-1] + 1*low[i-1];
    }

    int n;
    while(cin>>n && n!=-1)
    {
        cout<<high[n]<<", "<<low[n]<<endl;
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41727666/article/details/88427454