Cod sursa(job #1198550)

Utilizator teodor440Teodor Tonghioiu teodor440 Data 16 iunie 2014 09:50:42
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int fe(long long x){
    int a=0;
    while(x){
        x/=5;
        a++;
    }
    return a;
}

int main()
{
    long long p,x=1;
    f>>p;
    while(p>0){
        if(x%5==0&&x){
            p-=fe(x);
        }
        else p--;
        x++;
    }
    if(!p){
        x*=5;
        g<<x-5;
    }
    else g<<-1;

    return 0;
}