The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Given a set S of first N non-negative integers i.e. S = {0, 1, 2, ..., N}. Find number of ways of choosing a K size subset of S with the property that the XOR-sum of all chosen integers has exactly B set bits in its binary representation (i.e. the bits that are equal to 1). Since the answer can be large, output it modulo (109 + 7). Please refer to notes section for formal definition of XOR-sum.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The only line of each test case contains three space-separated integers N, K and B.
For each test case, output a single line containing the answer to the corresponding test case.
Input: 3 2 2 0 2 2 1 2 2 2 Output: 0 2 1
XOR-sum of n integers A[1], , , A[n] will be A[1] xor A[2] xor .. A[n]. By xor, we mean bit-wise xor.
Example case 1. There is no way to choose a subset of 2 integers from {0, 1, 2} such that the XOR-sum contains 0 set bits.
Example case 2. The two possible subsets in this case are {0, 1} and {0, 2}. In both cases the XOR-sum (1 and 2 respectively) contains exactly one set bit.
Example case 3. The only possible subset is {1, 2}.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll