Cod sursa(job #2666647)
| Utilizator | Data | 2 noiembrie 2020 11:51:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 95 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int cate_zerouri_are_factorial_de(int n)
{
int nr = 0;
while(n > 0)
{
nr += n / 5;
n /= 5;
}
return nr;
}
int main()
{
int p,step,pos = -1;
fin >> p;
step = 1 << 30;
while(step > 0)
{
if(cate_zerouri_are_factorial_de(pos + step) < p)pos += step;
step /= 2;
}
if(cate_zerouri_are_factorial_de(pos + 1) == p)
{
fout << pos + 1;
}
else fout << -1;
return 0;
}
