Cod sursa(job #1311800)
| Utilizator | Data | 8 ianuarie 2015 16:48:45 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#include <cmath>
#define nmax 400000020
using namespace std;
ifstream f("factorial.in");
ofstream g("factorial.out");
int numar, P;
int main()
{int Aux, x = 0;
f >> P;
if(P == 0) g<<1<<'\n';
else{
Aux = P;
numar = 25;
P *= 5;
while (numar <= P){
P -= ((P - 1) / numar) * 5;
numar *= 5;
}
numar /= 5;
while(numar >= 5){
x += P / numar;
numar /= 5;
}
if(x == Aux) g << P << '\n';
else g << -1 <<'\n';
}
return 0;
}
