Pagini recente » Statistici Popescu Filip (popfi) | Profil ovidiu1 | Monitorul de evaluare | Profil M@2Te4i | Cod sursa (job #1981514)
#include <cstdio>
using namespace std;
const int maxn = 15;
const int base = 1000000000;
int A[maxn];
int B[maxn];
void add()
{
int i = 1;
int tr = 0;
for(i = 1; i <= A[0] || tr > 0; i++)
{
A[i] = (tr += A[i] + B[i]) % base;
tr = tr / base;
}
A[0] = i - 1;
}
void cop(int A[], int B[]) /// pune A in B
{
for(int i = 0; i <= A[0]; i++)
B[i] = A[i];
}
int aux[maxn];
int main()
{
freopen("nunta.in", "r", stdin);
freopen("nunta.out", "w", stdout);
int n;
scanf("%d", &n);
A[0] = 1;
A[1] = 1;
B[0] = 1;
B[1] = 1;
n++;
for(int i = 3; i <= n; i++)
{
cop(A, aux);
add();
cop(aux, B);
}
for(int i = A[0]; i >= 1; i--)
printf("%d ", A[i]);
printf("\n");
return 0;
}