Description
已知a[1]=1,a[2]=1,a[n]=a[n-1]+a[n-2],求解a[n]的值,n<=90
Input
多组输入,每组一行,输入n,n<=90
Output
一行一个a[n]
#include<iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int a[100];
for (int i = 3; i <= n; i++) {
a[1] = 1;
a[2] = 1;
a[i] = a[i - 1] + a[i - 2];
}
cout << a[n];
}
return 0;
}
OJ提交后结果:
Wrong Answer50%