HDU - 2018

时间:2020-02-13 09:44:05   收藏:0   阅读:45

HDU - 2018

思路

打表,找规律,

技术图片

#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int f[N] = {0,1,2,3},k = 3;
int main() {
    int n;
    while(cin >> n && n) {
        if(n > k){
            while(k <= n) {
                k ++;
                f[k] = f[k - 1] + f[k - 3];
            }
        }
        cout << f[n] << endl;
    }
    return 0;
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!