Cod sursa(job #3157180)
Utilizator | Data | 14 octombrie 2023 16:15:04 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int x)
{
int c=0;
while(x){
c+=x/5;
x=x/5;
}
return c;
}
int main()
{
int n;
in>>n;
int s=0,d=5*n+1,r=d;
while(s<=d){
int mij=(s+d)/2;
if(zero(mij)>=n){
r=mij;
d=mij-1;
}
else
s=mij+1;
}
if (zero(r)!=n)
r=-1;
out<<r;
return 0;
}