Cod sursa(job #3301058)
Utilizator | Data | 21 iunie 2025 13:46:33 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
long long n, p, mij;
int main()
{
in>>p;
long long st=1, dr=10000000;
while(st<=dr){
mij=(st+dr)/2;
int q=5, s=0;
while(q<=mij){
s+=mij/q;
q*=5;
}
if(s<p)
st=mij+1;
else dr=mij-1;
}
out<<st;
}