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

#define _CRT_SECURE_NO_WARNINGS
#define For(i,a,b) for (long i(a),_b(b); i <= _b; ++i)

char buf[1024*1024];

bool isEven(long a,long b)
{       bool result=0;
        if(b%2==0)
                result=0;
        else
                {
                 double ad=0.00;
                 for(int j=0;j<=30;j++)
                {
                if(int(ad)==a)
                { break;}
                ad=ad+1.00;
                }
                        long PD=long(pow(2.00,ad));
                        if(b<PD)
                        result=0;

                        else
                        {
                        for(long i=PD;i<=100000000;i+=PD)
                         {
                         if(b==i-1)
                           {
                           result=1;
                           break;
                           }
                         }
                        }
                        }
        return result;
}

int main() {
        freopen("A-large.in", "rt", stdin);
        freopen("output_Snapper_Chain.txt", "wt", stdout);

    gets(buf);
    long size=atoi(buf);

        
        For(test, 1, size)
  {
  //    cout<<"No. of loops"<<test;
        long N;
        long K;
                
        scanf("%d%d", &N, &K);
//              cout<<"N"<<N<<"K"<<K;
                
        bool res=isEven(N,K);
            if(res)
                printf("Case #%d: ON\n", test);
                else
                printf("Case #%d: OFF\n", test);
    }
        exit(0);
}


---------------------------------------------------------------------------------------------------------------------------
Can anybody tell me the errors in the code.....i have done this
problem using the simple concept which i know....it is not giving
right output....

Brief explanation of code:
i have first converted the long taken from file into the double using
for loop..then using pow function i have found 2^N and then found
whether k==2^N-1;

_____
Aamir

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to