Cod sursa(job #1198564)

Utilizator teodor440Teodor Tonghioiu teodor440 Data 16 iunie 2014 10:39:01
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>
 
using namespace std;
 
ifstream f("fact.in");
ofstream g("fact.out");
 
int main()
{
    long long p,x=1;
    long i;
    int a;
    f>>p;
    while(p>0){
        if(x%5==0&&x){
            a=0;
            for(i=5;i<=x;i*=5) a++;
            p-=a+1;
        }
        else p--;
        x++;
    }
    if(!p){
        x*=5;
        g<<x-5;
    }
    else g<<-1;

    return 0;
}

}