Cod sursa(job #3349572)
| Utilizator | Data | 31 martie 2026 19:26:47 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
ll f(ll x){
ll sol = 0;
while(x/5 != 0){
x /= 5;
sol += x;
}
return sol;
}
int main(){
ll p, n=-1;
fin >> p;
ll l = 1, r =1e10;
while(l <= r){
ll mid = l + (r-l)/2;
if(f(mid) >= p){
r = mid-1;
n = mid;
}
else if (f(mid) < p){
l = mid+1;
}
}
fout << n;
return 0;
}