Mai intai trebuie sa te autentifici.
Cod sursa(job #1685004)
Utilizator | Data | 11 aprilie 2016 13:53:20 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <fstream>
#include <iostream>
#include <climits>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int n;
long long st = 1, dr = 100000000, piv;
long long lol(long long x)
{
int y = 0;
int p = 5;
while(p <= x)
{
y += (x / p);
p *= 5;
}
return y;
}
void search()
{
while(st <= dr)
{
piv = st + (dr - st) / 2;
if(lol(piv) <= n) st = piv + 1;
else dr = piv - 1;
}
out << dr;
}
int main()
{
in >> n;
search();
//cout << lol(50);
//cin >> n;
return 0;
}