#include<stdio.h>
#define LL long long
int main()
{
int T;
scanf("%d",&T);
while(T--){
LL n, ans = 0;
scanf("%lld",&n);
LL sum =n + n*(n-1)/2;
for(LL i = 1;i <=n;i *= 2){
ans += i;
}
printf("%lld\n",sum-2*ans);
}
return 0;
}CodeForces - 598A
最新推荐文章于 2019-11-05 23:36:19 发布
本文展示了一个使用C语言编写的程序,该程序通过输入一个整数n来计算特定数学序列的值。程序首先计算了从1到n的累加和加上n*(n-1)/2,然后减去另一个通过迭代计算得到的序列之和的两倍。

210

被折叠的 条评论
为什么被折叠?



