Cod sursa(job #1572626)
Utilizator | Data | 18 ianuarie 2016 23:56:56 | |
---|---|---|---|
Problema | Factorial | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n,i=1,nr,P,x,ok=1;
int main()
{
f>>P;
if(P==0)
{
g<<1;
return 0;
}
while(ok==1)
{
i++;
x=i;
while(x%5==0)
{
nr++;
x/=5;
}
if(nr==P) {ok=0;g<<i;}
if(nr>P) {ok=0;g<<-1;}
}
return 0;
}