Cod sursa(job #1364422)
Utilizator | Data | 27 februarie 2015 17:37:07 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
int p,n,z,x;
f>>p;
if(p==0)
g<<"1";
n=0;
do
{
n=n+5;
z=5;
x=0;
while(z<=n)
{
x=x+n/z;
z=z*5;
}
}while(x<p);
if(x==p)
g<<n;
else
g<<"-1";
return 0;
}