Cod sursa(job #1553474)

Utilizator BlaugranasEnal Gemaledin Blaugranas Data 19 decembrie 2015 22:17:09
Problema Nunta Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<cstdio>
#include<cstring>
FILE *f=fopen("nunta.in","r"),*g=fopen("nunta.out","w");
short n,i,t,a[210],b[210],c[210];
int main() {
    fscanf(f,"%hd",&n),a[0]=b[0]=c[0]=a[1]=b[1]=c[1]=1;
    for(;n>1;n--) {
        for(i=1;i<=a[0]||i<=b[0]||t;i++,t/=10)
            c[i]=(t+=a[i]+b[i])%10;
        c[0]=i-1,memcpy(a,b,sizeof(b)),memcpy(b,c,sizeof(c));
    }
    for(i=c[0];i;i--)
        fprintf(g,"%hd",c[i]);
}