Cod sursa(job #3141296)
| Utilizator | Data | 13 iulie 2023 14:40:11 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
using namespace std;
const long long NMAX=1e18;
typedef long long ll;
ll nrCifre(ll x)
{
ll rez=0;
while(x)
{
rez+=x/5;
x/=5;
}
return rez;
}
int main() {
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
ll dr, st, n;
cin>>n;
st=1;dr=NMAX;
while(st<dr)
{
ll mij=(dr+st)/2;
if(nrCifre(mij)<n)
st=mij+1;
else
dr=mij;
}
if(nrCifre(st) == n){
cout << st << '\n';
}
else{
cout << -1 << '\n';
}
return 0;
}
