Cod sursa(job #2025326)

Utilizator cella.florescuCella Florescu cella.florescu Data 22 septembrie 2017 16:14:24
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <cstdio>
unsigned char a[211],b[211],x;
int main(){
    int n,j;
    fscanf(fopen("nunta.in","r"),"%d",&n);
    a[0]=a[1]=b[0]=b[1]=1;
    for(int i=1;i<n;++i){
      int t=0;
      for(j=1;j<=b[0]||t;++j,t/=10){
        x=b[j];
        b[j]=(t+=a[j]+b[j])%10;
        a[j]=x;
      }
      a[0]=b[0];
      b[0]=j-1;
    }
    FILE*fout=fopen("nunta.out","w");
    for(int i=b[0];i>0;--i)
      fprintf(fout,"%d",b[i]);
    return 0;
}