Cod sursa(job #743567)
Utilizator | Adascalitei Radu mosu | Data | 4 mai 2012 22:17:55 |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
long p, pow, zeros, i, no;
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>p;
fin.close();
for(i = 0, zeros = 0, pow = 0, no = 5; zeros < p; i += 5)
{
if(i == no)
{
++pow;
zeros += pow;
no *= 5;
}
else
++zeros;
}
if(zeros == p)
fout<<i;
else
fout<< -1;
fout.close();
return 0;
}