杭电 -- 2045

 

题意及思路

题意:

思路:

代码

#include <iostream>
#include <cstdio>

using namespace std;

long long color[60];

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n; // n cells
    color[1] = 3;
    color[2] = 6;
    color[3] = 6;
    while(scanf("%d",&n)!=EOF){
        for(int i=4;i<=n;i++) color[i] = color[i-1] + 2*color[i-2];
        cout << color[n] << endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/kyrie211/p/11254056.html