Cod sursa(job #1364425)
Utilizator | Data | 27 februarie 2015 17:40:21 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream f("DATE.IN");
ofstream g("date.out1");
int main()
{
int N,P,x,a;
f>>P;
if (P==0) g<<1;
N=0;
do
{
N=N+5;
x=0;
a=5;
while (a<=N)
{
x=x+N/a;
a=a*5;
}
} while(x<P);
if(x==P) g<<N;
else g<<"-1";
return 0;
}