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

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.