bit problem

Hi give me a hint for following problems

1 The numbers are exactly N bits wide and they have no leading zeros.
2 The frequency of zeros and ones are equal.
3 The numbers are multiples of K.


for #1 if N is 6
4 should looks like 000100??

for #2 how do u check the frequency is same?
count(number, 0) == count(number, 1)

edit: pseudocode, not the std::count
Last edited on
actually i thought its testing the number of 0 and 1 but
the output look little bit weird test this



Sample Input
5
6 3
6 4
6 2
26 3
64 2
Sample Output
Case 1: 1
Case 2: 3
Case 3: 6
Case 4: 1662453
Case 5: 465428353255261088

closed account (o1vk4iN6)
for #1 if N is 6
4 should looks like 000100??


N would be 3 here, as there are 3 leading zeroes. Or i guess it would be invalid since there are leading zeroes ? How every you want to handle that really.
Last edited on
Topic archived. No new replies allowed.