Cod sursa(job #843855)
Utilizator | Data | 28 decembrie 2012 15:48:25 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | 23dezile_2 | Marime | 0.39 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int p,ok=0,n, fives=0,pp;
fin>>p;
for(n=1;ok==0 && n>0;n++)
{
pp=n;
while(pp%5==0){
if (pp%5==0) { fives++; pp=pp/5;}
}
if(fives>=p)
ok=n;
}
if(fives != p) fout<<-1;
else fout<<ok;
fout.close();
fin.close();
return 0;
}