#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <cmath>
#define Pi acos(-1)
using namespace std;
int main(){
int g;
long long ans;
vector <long long> fib;
while(cin >> g){
if(g == 0)break;
fib.push_back(0);
fib.push_back(1);
for(int i = 1; i <= g; i++){
ans = fib[i-1] + fib[i];
fib.push_back(ans);
}
cout << ans << endl;fib.clear();
}
return 0;
}
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <cmath>
#define Pi acos(-1)
using namespace std;
int main(){
int g;
long long ans;
vector <long long> fib;
while(cin >> g){
if(g == 0)break;
fib.push_back(0);
fib.push_back(1);
for(int i = 1; i <= g; i++){
ans = fib[i-1] + fib[i];
fib.push_back(ans);
}
cout << ans << endl;fib.clear();
}
return 0;
}
No comments:
Post a Comment