Cod sursa(job #2023754)

Utilizator andreicoman299Coman Andrei andreicoman299 Data 19 septembrie 2017 14:07:36
Problema Nunta Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <stdio.h>
unsigned char F[2][500];
int main(){
    FILE*fi,*fo;
    fi=fopen("nunta.in","r");
    fo=fopen("nunta.out","w");
    short n;
    fscanf(fi,"%hd", &n);
    if(n == 1){
        fprintf(fo,"1");
        return 0;
    }
    F[0][0] = 1;
    F[0][1] = 1;
    F[1][0] = 1;
    F[1][1] = 2;
    bool ind = 1;
    for(int j = 3; j <= n; j++){
        int i, t = 0;
        for(i = 1; i <= F[0][0] || i <= F[1][0] || t; i++, t/=10)
            F[1 - ind][i] = (t += F[0][i] + F[1][i]) % 10;
        F[1 - ind][0] = i - 1;
        ind = !ind;
    }

    for(int i = F[ind][0]; i > 0; i--)
        fprintf(fo,"%d", F[ind][i]);
    return 0;
}