Pagini recente » Cod sursa (job #1884792) | Cod sursa (job #544047) | Cod sursa (job #2011164) | Cod sursa (job #455414) | Cod sursa (job #2021052)
#include <iostream>
#include <fstream>
using namespace std;
ifstream si("nunta.in");
ofstream so("nunta.out");
short q[1005],a[1005],b[1005];
int main()
{
int n,k;
short x,t;
si>>n;
a[1]=b[1]=1;
k=1;
short nr;
for(int i=2;i<=n;++i)
{
t=0;
for(int j=1;j<=k;j++)
{
nr=b[j];
x=a[j]+b[j]+t;
b[j]=x%10;
t=x/10;
a[j]=nr;
}
if(t>0)
{
k++;
b[k]=t;
}
}
if(n==1)
so<<1;
else
for(int i=k;i>0;--i)
{
so<<b[i];
}
return 0;
}