solution : Xor Equality | codechef | Problem Code: XOREQUAL

Xor Equality Problem Code: XOREQUAL

For a given N, find the number of ways to choose an integer x from the range [0,2N1] such that x(x+1)=(x+2)(x+3), where  denotes the bitwise XOR operator.

Since the number of valid x can be large, output it modulo 109+7.

Input

  • The first line contains an integer T, the number of test cases. Then the test cases follow.
  • The only line of each test case contains a single integer N.

Output

For each test case, output in a single line the answer to the problem modulo 109+7.

Constraints

  • 1T105
  • 1N105

Subtasks

Subtask #1 (100 points): Original Constraints

Sample Input 1 

2
1
2

Sample Output 1 

1
2

Explanation

Test Case 1: The possible values of x are {0}.

Test Case 2: The possible values of x are {0,2}.



solution : 

#include <bits/stdc++.h>

using namespace std;

#define l 1000000007;

int main() {

int t ;

cin.tie(0);

ios::sync_with_stdio(false);

cin >> t;

while(t--)

{

    long long int n ;

    cin >> n ;

   long  long int count = 1;

    for(int i = 1 ; i <= (n-1); i++ )

    {

        count = (count *2) % l;

    }

    cout << count << "\n";

}

return 0;

}


Comments