Cod sursa(job #1509605)

Utilizator SunKaiBursuc Tudor Gheorghe SunKai Data 24 octombrie 2015 09:16:09
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 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;
}