You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/TangDou/AcWing/DP/GunDongShuZhu_ShangTaiJie_2...

23 lines
353 B

#include <bits/stdc++.h>
using namespace std;
//用例:
/*
20
输出:
10946
*/
int f[3];
int n;
int solve() {
f[0] = 1, f[1] = 2;
for (int i = 2; i < n; i++)
f[i % 3] = f[(i - 1) % 3] + f[(i - 2) % 3];
return f[(n - 1) % 3];
}
int main() {
scanf("%d", &n);
printf("%d\n", solve());
return 0;
}