Cod sursa(job #1218011)
Utilizator | Data | 9 august 2014 04:30:15 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
unsigned long long p,n;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
fin>>p;
if(!p)
{
fout<<"1";
return 0;
}
n=5;
while(p>=n)
{
if(p%n)
p-=p/n;
else
{
fout<<"-1";
return 0;
}
n*=5;
}
fout<<p*5;
return 0;
}