Xor Equality Problem Code: XOREQUAL
For a given , find the number of ways to choose an integer from the range such that , where denotes the bitwise XOR operator.
Since the number of valid can be large, output it modulo .
Input
- The first line contains an integer , the number of test cases. Then the test cases follow.
- The only line of each test case contains a single integer .
Output
For each test case, output in a single line the answer to the problem modulo .
Constraints
Subtasks
Subtask #1 (100 points): Original Constraints
Sample Input 1
2
1
2
Sample Output 1
1
2
Explanation
Test Case : The possible values of are .
Test Case : The possible values of are .
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
Post a Comment