Cod sursa(job #1198549)

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

using namespace std;

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

int f(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-=f(x);
        }
        else p--;
        x++;
    }
    if(!p){
        x*=5;
        g<<x-5;
    }
    else g<<-1;

    return 0;
}