LightOj 1116 Ekka Dokka







#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int l,m,t,w,y,z,h,x,p,q,n;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%lld",&t);
    for(l=1;l<=t;l++)
    {
        cin>>w;
        p=0;


        for(y=2;y<=w/2;y=y*2)
        {

            z=y;
            n=w/z;
            h=w%z;
            //cout<<n<<endl;
            if(n%2==1 && h==0)
            {
                    m=z;
                    x=n;
                    p=1;
                    break;
            }
        }


            if(p==1)
            {
                printf("Case %lld: %lld %lld\n",l,x,m);
            }
            else
            {
                printf("Case %lld: Impossible\n",l);
            }
        }


    return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment