HDU - 2018

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;
}
posted @ 2020-02-13 00:50  南风--  阅读(122)  评论(0编辑  收藏  举报