Cod sursa(job #1184057)
| Utilizator | Data | 10 mai 2014 23:25:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
using namespace std;
inline int count_zero(int x)
{
int nr=0;
while (x) {
nr+=x/5;
x/=5;
}
return nr;
}
int main()
{
ifstream fIn("fact.in");
ofstream fOut("fact.out");
int k, li, ls, mij;
fIn>>k;
if (!k){ fOut<<1; return 0; }
li=1, ls=k*5;
while (li<=ls) {
mij=(li+ls)>>1;
count_zero(mij)<k ? li=mij+1 : ls=mij-1;
}
fOut<<(count_zero(li)==k ? li : -1);
return 0;
}
