Pagini recente » Cod sursa (job #2542549) | Cod sursa (job #1977258) | Cod sursa (job #1447637) | Cod sursa (job #2469957) | Cod sursa (job #754378)
Cod sursa(job #754378)
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("nunta.in");
ofstream out("nunta.out");
int a[210], b[210], c[210];
int main()
{
int N, i, j, t = 0;
in >> N;
if(N <= 3){
out << N;
return 0;
}
a[0] = b[0] = c[0] = 1;
a[1] = 1; b[1] = c[1] = 2;
for(i = 3; i <= N; ++i, t = 0){
for(j = 1; j <= c[0] || j <= a[0] || t; ++j, t /= 10)
c[j] = (t += c[j] + a[j]) % 10;
c[0] = j - 1;
for(j = 0; j <= b[0]; ++j)
a[j] = b[j];
for(j = 0; j <= c[0]; ++j)
b[j] = c[j];
}
for(i = c[0]; i; --i)
out << c[i];
return 0;
}