吃糖果(和斐波那契数列递推差不多) 题解:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
LL dp[30];
int main()
{
dp[1] = 1, dp[2] = 2;
for(int i = 3; i <= 20; i ++)
dp[i] = dp[i - 1] + dp[i - 2];
while(cin >> n)
{
cout << dp[n] << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发