吃糖果 题解:
请问为什么我的做法哪里有问题呀
#include<iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
long long int* a = new long long int[n];
a[1] = 1;
a[2] = 2;
for (int i = 3; i <= n; i++) {
a[i] = a[i - 1] + a[i - 2];
}
cout << a[n] << endl;
}
return 0;
}
登录后发布评论
hello