Codeforces Manthan, Codefest 16 633B - A Trivial Problem Solution
Problem Link: https://codeforces.com/problemset/problem/633/B
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include<bits/stdc++.h>
using namespace std;
int five(int n)
{
int sz=0;
while(n)
{
sz+=n/5;
n/=5;
}
return sz;
}
int main()
{
int t,i;
int l=0,r=1000000000,v;
cin>>v;
while(l<=r)
{
int mid=l+(r-l)/2;
if(five(mid)>=v)
r=mid-1;
else
l=mid+1;
}
if(five(l)==v)
{
cout<<"5"<<endl;
cout<<l<<" "<<l+1<<" "<<l+2<<" "<<l+3<<" "<<l+4<<endl;
}
else
cout<<"0"<<endl;
}
No comments