Cod sursa(job #3338337)
| Utilizator | Data | 2 februarie 2026 19:03:12 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fact.in");
ofstream fout("fact.out");
long long f(int n){
long long x=5,numere=0;
while (x<=n){
numere+=n/x;
x=x*5;
}
return numere;
}
int main()
{
int n;
fin >> n;
int st=1,dr=INT_MAX;
while (st<dr){
int mij=(st+dr)/2;
if (n>f(mij))
st=mij+1;
else
dr=mij;
}
fout << st;
return 0;
}