Cod sursa(job #1699575)

Utilizator alittlezzCazaciuc Valentin alittlezz Data 7 mai 2016 20:37:12
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <stdio.h>

using namespace std;

char x[211], y[211];
short lx,ly;

void sum() {
    int xx,i, T = 0;
    char ch;
    ly = lx;
    for(i = 1; i <= ly; i++) {
        xx = (x[i]-'0')+(y[i]-'0')+T;
        T = xx/10;
        ch = x[i];
        x[i] = (xx%10)+'0';
        y[i] = ch;
    }
    if(T){
        x[++lx] = T+'0';
    }
}

int main() {
    short N,i;
    freopen("perioada01.in", "r", stdin);
    freopen("perioada01.out", "w", stdout);
    scanf("%d", &N);
    N++;
    for(i = 1;i <= 205;i++){
        x[i] = y[i] = '0';
    }
    x[1] = '1';
    lx = 1;
    N--;
    while(N-- % 1332028) {
        sum();
    }
    for(i = lx; i >= 1; i--) {
        printf("%d", x[i]-'0');
    }
    return 0;
}