154. Factorial
memory limit per test: 4096 KB
output: standard output
Input
Output
Sample test(s)
Input
#include <bits/stdc++.h>
using namespace std;
int f(int x){
int now=0;
while(x>0){
now+=x/5;
x/=5;
}
return now;
}
void solve(){
int q;
scanf("%d",&q);
int left=1,right=500000000,ans=500000005;
while(left<=right){
int mid=(left+right)>>1;
if(f(mid)<q){
left=mid+1;
}
else if(f(mid)==q){
ans=min(ans,mid);
right=mid-1;
}
else{
right=mid-1;
}
}
if(ans==500000005){
printf("No solution");
return;
}
printf("%d",ans);
}
int main(){
solve();
return 0;
}