Pagini recente » Cod sursa (job #2434871) | Cod sursa (job #2718881) | Cod sursa (job #2729068) | Cod sursa (job #493224) | Cod sursa (job #2480931)
#include <bits/stdc++.h>
using namespace std;
typedef int el_mundo[1005] ;
el_mundo k[1005];
void Adunare(el_mundo x,el_mundo y){
int i,t=0;
if(x[0]<y[0])
x[0]=y[0];
for(i=1;i<=x[0];i++,t/=10)
{
t=x[i]+y[i]+t;
x[i]=t%10;
}
if(t)
x[++x[0]]=t;
}
void AtribMic(el_mundo x, int n){
x[0]=0;
if(n==0)
x[(x[0]=1)]=0;
else
for(;n;n/=10)
x[++x[0]]=n%10;
}
ifstream in("nunta.in");
ofstream out("nunta.out");
int main(){
int n;
in>>n;
AtribMic(k[0], 1);
AtribMic(k[1], 1);
for(int i = 2; i <= n;i++){
Adunare(k[i], k[i-1]);
Adunare(k[i], k[i-2]);
}
for(int i = k[n][0]; i > 0; i--) out << k[n][i];
}