Wednesday, June 8, 2011

11986 - Save from Radiation


#include<iostream>
#include<cstdio>
using namespace std;

typedef long long Long;
int CountRat(Long s);

int main()
{
    int t,k=1;
    Long n;
    //freopen("in.txt","r",stdin);
    scanf("%d",&t);

    for(k=1;k<=t;k++)
    {
        scanf("%lld",&n);
        printf("Case %d: %d\n",k,CountRat(n+1));
    }
    return 0;
}

int CountRat(Long s)
{
    Long tmp=1;
    int count=0;
    if(s<2)return 0;

    while(s>tmp)
    {
        tmp = tmp << 1;
        count++;
    }
    return count;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.