Cod sursa(job #2303956)
| Utilizator | Data | 17 decembrie 2018 12:02:53 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.67 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long catidezero(long long P)
{
long long i=5,contor=0;
while (i<=P)
{
contor+=(P/i);
i*=5;
}
return contor;
}
int main()
{
long long P,cP;
fin >> P;
if (P==0)
{
cP=1;
fout << cP;
}
else
{
cP=P;
while (catidezero(cP)<P)
{
++cP;
}
if (catidezero(cP)==P)
{
fout << cP;
}
else
{
cP=-1;
fout << cP;
}
}
return 0;
}
