Cod sursa(job #1509613)

Utilizator SunKaiBursuc Tudor Gheorghe SunKai Data 24 octombrie 2015 09:21:02
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
    int P,i,j;
    fin>>P;
    i=0;
    if(P==0)fout<<1;
    else
    {
        while(P>0)
    {
        i=i+5;
        j=i;
        P--;
        j=j/5;
        while(j%5==0)
        {
            j=j/5;
            P--;
        }
    }
    if(P<0)fout<<-1;
    else fout<<i;
    }
    return 0;
}