Cod sursa(job #277527)
| Utilizator | Data | 11 martie 2009 19:35:45 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.83 kb |
#include<iostream.h>
#include<fstream.h>
long long p;
ifstream f("fact.in");
ofstream g("fact.out");
inline void citire()
{
f>>p;
f.close();
}
inline int cautare()
{
long long h, aux, cinci=0;
h=5;
while(cinci<p)
{
aux=h;
while(aux%5==0)
{
aux/=5;
cinci++;}
h+=5;
}
if(cinci==p) return h-5;
else return 1;
}
main()
{
citire();
if(p==0) g<<'1';
else
{
if(cautare()==1) g<<'-1';
else g<<cautare();}
g.close();
}
