Accepted solution

Virtual Judge Parity Solution.

Open original problem
Source code

#include <iostream>

#include<stdio.h>

 

using namespace std;

 

long long int binary(long long int n)

{

     long long int temp = n;

     long long int count=0;

    while(temp > 0)

    {

        if(temp%2==1)

        {

            count++;

        }

        temp/=2;

    }

    return count;

}

 

int main()

{

   int T,test=0;

    cin>>T;

    while(T>0)

    {

        test++;

        long long int n;

        cin>>n;

        long long int count = binary(n);

      

         if(count%2==0)

         {

             cout<<"Case "<<test<<": even"<<endl;

         }

         else

         {

             cout<<"Case "<<test<<": odd"<<endl;

         }

       T--;

    }

    return 0;

}
Join the discussion

Add your comment