Cod sursa(job #3304577)
| Utilizator | Data | 25 iulie 2025 10:30:45 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <bits/stdc++.h>
using namespace std;
long long n, st=1, dr=1000000000;
int check(long long nr)
{
long long p=5, nrzero=0;
while(p<=nr)
{
nrzero+=nr/p;
p*=5;
}
return nrzero;
}
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
while(st<=dr)
{
long long mij=(st+dr)/2;
if(check(mij)<n)
st=mij+1;
else dr=mij-1;
}
//cout << check(st) << " ";
if(check(st)==n)
cout<<st;
else cout<<-1;
return 0;
}
