Pagini recente » Cod sursa (job #2237303) | Cod sursa (job #1899709) | Cod sursa (job #2100807) | Cod sursa (job #2572733) | Cod sursa (job #1581601)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("nunta.in");
ofstream fout ("nunta.out");
typedef int huge[225];
int n;
huge x1, x2, x3;
void aduna(huge a, huge b)
{
int i, t=0;
for (i=1; i<=a[0] || i<=b[0] || t; i++, t/=10)
{
if (i > a[0]) a[i]=0;
if (i > b[0]) b[i]=0;
a[i]=(t+=a[i]+b[i])%10;
}
a[0]=i-1;
}
void copie(huge a, huge b)
{
for (int i=0; i<=b[0]; i++)
a[i]=b[i];
}
int main()
{
ios_base::sync_with_stdio(false);
int i;
fin >> n;
if(n==1)
{
printf("1\n");
return 0;
}
x1[0]=x1[1]=x2[0]=x2[1]=1;
for(i=1; i<n; i++)
{
copie(x3, x2);
aduna(x2, x1);
copie(x1, x3);
}
for (i=x2[0]; i; i--)
fout << x2[i];
fin.close();
fout.close();
return 0;
}