Cod sursa(job #2545137)
Utilizator | Data | 12 februarie 2020 20:53:59 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int yeet(int x){
int ynot=0,yes=5;
while(yes<=x){
ynot+=x/yes;
yes*=5;
}
return ynot;
}
int main()
{
int P,st=0,dr=2000000000,no_u=-1,check_mid;
fin>>P;
while(st<=dr){
check_mid=(st+dr)/2;
if(yeet(check_mid)==P)
no_u=check_mid;
if(yeet(check_mid)>=P)
dr=check_mid-1;
else
st=check_mid+1;
}
if(no_u==0)
fout<<1;
else
fout<<no_u;
return 0;
}