Cod sursa(job #726947)

Utilizator misinoonisim necula misino Data 27 martie 2012 17:28:22
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream>
using namespace std;
ifstream f("nunta.in");
ofstream g("nunta.out");
int n,i,j,t,y,p,k,m,a[20],b[20],c[200];
int main()
{f>>n;
a[1]=1;
b[1]=1;
m=1;
p=1;
for(i=1;i<n;++i)
{t=0;
for(j=1;j<=p;++j)
{y=a[j]+b[j]+t;
t=y/10;
c[j]=y%10;
}
k=p;
if(t!=0)
{++k;
c[k]=t;
t=0;
}
for(j=1;j<=p;++j)
	a[j]=b[j];
m=p;
for(j=1;j<=k;++j)
	b[j]=c[j];
p=k;
}
for(i=p;i>=1;--i)
	g<<c[i];
g<<'\n';
f.close();
g.close();
return 0;
}