Trivial Problem Codeforces Solution

Trivial Problem Codeforces Solution

In this post, the Trivial Problem Codeforces Solution is given. Question details : Manthan, Codefest 16, problem: (B) A Trivial Problem.

Trivial Problem Codeforces Solution

#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
ll zero(ll n)
{
ll count =0;
while(n)
{
n /= 5 ;
count += n ;
}
return count ;
}
int main()
{
ll n ; cin >> n ;
ll low = 1 ;
ll high = 1e18 ;
while((high - low) > 1)
{
ll mid = low+(high-low)/2;
ll count = zero(mid);
if(count >= n)
{
high = mid ;
}
else low = mid ;
}
ll ans ;
if(zero(low) == n)
{
ans = low ;
}
else ans = high ;
vector<int> f ;
while(zero(ans) == n)
{
f.push_back(ans);
ans++;
}
cout << f.size() << endl;
for(auto x : f)
{
cout << x << " " ;
}
}

Trivial Problem Codeforces Solution by Vishal Vaibhab (IIT BHU). If you like TheCode11, then do follow us on Facebook, Twitter and Instagram.

Previous Post Next Post

Contact Form