TOUGH - Bits. Exponents and Gcd
Rastas's has been given a number n. Being weak at mathematics, she has to consider all the numbers from 1 to 2n - 1 so as to become perfect in calculations. (You can assume each number is consider as a soldier).
We define the strength of number i as the number of set bits (bits equal to 1) in binary representation of number i.
If the greatest common divisor of numbers a and b is gcd(a, b),
Rastas would like to calculate the function S which is equal to:
As the friend of Rastas, it's your duty to calculate S modulo 109 + 7.
The first line of the input contains the number of test cases, T. Each of the next T lines contains an integer n, as mentioned in the question
For each value of n given, find the value of the function S.
Sum of n over all test cases doesn't exceed 2500.
Nice Problem, enjoyed solving it.
getting tle..any suggestions??
(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
Nice math problem ;-)