Monday 21 January 2013

9948. Will it ever stop Problem code: WILLITST

#include<stdio.h>
int main()
{
    long long int  n;
    while(scanf("%lld",&n)!=EOF)
    {
        if((n&(n-1))==0)
            printf("TAK\n");
        else
            printf("NIE\n");
    }
    return 0;
}

1 comment:

  1. if((n&(n-1))==0)
    how does this statement checks if n is a power of 2 ?

    ReplyDelete