Cod sursa(job #1218009)
Utilizator | Data | 9 august 2014 04:28:54 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 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;
n=5;
while(p>=n)
{
if(p%n)
p-=p/n;
else
{
fout<<"-1";
return 0;
}
n*=5;
}
fout<<p*5;
return 0;
}