Pagini recente » Cod sursa (job #12405) | Cod sursa (job #377879) | Cod sursa (job #2437189) | Cod sursa (job #2373576) | Cod sursa (job #754379)
Cod sursa(job #754379)
#include<cstdio>
using namespace std;
/*ifstream in("nunta.in");
ofstream out("nunta.out");*/
int a[210], b[210], c[210];
int main()
{
freopen("nunta.in", "r", stdin);
freopen("nunta.out", "w", stdout);
int N, i, j, t = 0;
//in >> N;
scanf("%d", &N);
if(N <= 3){
//out << N;
printf("%d", 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];
printf("%d", c[i]);
return 0;
}