HDU - 2018

HDU - 2018

Thinking

Hit the table, find the law,

#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;
}

Guess you like

Origin www.cnblogs.com/lukelmouse/p/12302018.html