Cod sursa(job #2103477)
| Utilizator | Data | 10 ianuarie 2018 12:56:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <cstdio>
#include <iostream>
using namespace std;
int zerouri(int x){
int puter = 5, rez = 0;
while(puter <= x){
rez += x / puter;
puter *= 5;
}
return rez;
}
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int p;
scanf("%d", &p);
int pas = 1 << 30, rasp = 0;
while(pas){
if(zerouri(pas + rasp) <= p)
rasp += pas;
pas /= 2;
}
rasp -= 4;
if(p == 0)
rasp = 1;
if(!rasp)
printf("-1");
else
printf("%d", rasp);
return 0;
}
