#CF598A. Tricky Sum
Tricky Sum
题目描述
In this problem you are to calculate the sum of all integers from to , but you should take all powers of two with minus in the sum.
For example, for the sum is equal to , because , and are , and respectively.
Calculate the answer for values of .
输入格式
The first line of the input contains a single integer ( ) — the number of values of to be processed.
Each of next lines contains a single integer ( ).
输出格式
Print the requested sum for each of integers given in the input.
题目大意
简明题意:
该题目有多组数据,每组数据给出一个n,让你求出从1到n的和,但是其中每当遇到一个数是2的次幂时,就要变加为减。例如输入n=4,那么计算算式为-1-2+3-4=-4,因为1是2^0,2是2^1,4是2^2。共有t组数据。
2
4
1000000000
-4
499999998352516354
提示
The answer for the first sample is explained in the statement.