Please enter your email address or userHandle.
You are given a number N. Find the total count of set bits for all numbers from 1 to N(both inclusive).
The first line of input contains an integer T denoting the number of test cases. T testcases follow. The first line of each test case is N.
For each testcase, in a new line, print the total count of all bits.
1 ≤ T ≤ 100
1 ≤ N ≤ 103
An easy way to look at it is to consider the number, n = 4:
0 0 0 = 0
0 0 1 = 1
0 1 0 = 1
0 1 1 = 2
1 0 0 = 1
Therefore , the total number of bits is 5.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.