Saturday, April 29, 2017

UVA ONLINE JUDGE PROBLEM 11636

UVA ONLINE JUDGE  

PROBLEM 11636

Hello World!
 
Solution:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,j;


    for(int i=1;; i++)
    {
        cin>>n;
        if(n<0) break;

        for(j=0; j<=n; j++)
        {
            if(pow(2,j)==n)
            {
                printf("Case %d: %d\n",i,j);
                break;
            }
            if(pow(2,j+1)>n)
            {
                 printf("Case %d: %d\n",i,j+1);

                break;
            }
        }
    }
    return 0;
}
 
//Language:C++;

No comments:

Post a Comment