Pagini recente » Cod sursa (job #98098) | Cod sursa (job #2689491) | Cod sursa (job #10272) | Cod sursa (job #3216821) | Cod sursa (job #934877)
Cod sursa(job #934877)
#include <cstdio>
using namespace std;
#define Nmax 500
int A[Nmax], B[Nmax], C[Nmax];
int N;
int main(){
freopen("nunta.in", "r", stdin);
freopen("nunta.out", "w", stdout);
scanf("%d", &N);
A[0]=1;
A[1]=2;
B[0]=1;
B[1]=1;
if ( N == 1 ){
printf("1\n");
return 0;
}
for ( int j = 3; j <= N; j++ ){
int T = 0, i;
for ( i = 0; i <= A[0]; i++ )
C[i] = A[i];
for ( i = 1; i <= A[0] || i <= B[0] || T; i++, T /= 10 )
A[i] = ( T += A[i] + B[i] ) % 10;
A[0] = i - 1;
for ( i = 0; i <= C[0]; i++ )
B[i] = C[i];
}
for ( int i = A[0]; i; i-- )
printf("%d", A[i]);
return 0;
}