AcWing
717. 简单斐波那契
f[i] = f[i-2] + f[i-1]
.
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 50;
int a[N];
int main(){
cin >> n;
a[1] = 0, a[2] = 1;
for(int i = 3; i <= n; i++) a[i] = a[i - 2] + a[i - 1];
for(int i = 1; i <= n; i++) cout << a[i] << " \n"[i == n];
return 0;
}