cfedu / A /合計



Cfedu Summation



トピック接続

アイデア:

Directly labeled with an array of 2 ^ n, n belonging to the (0 ~ 31) LL, or the INT can be, not burst. But ans use LL. #include #include #include #include #include #include #include #include using namespace std typedef pair<int, int> pa typedef long long LL const int inf=1e9//INT_MAX const int maxn=100+10 LL ma[100] void init() { LL x=1 for(int i=0i<=32i++){ ma[i]=x x*=2 } } int main () { init() int Tscanf('%d',&T) while(T--) { LL n LL ans=0 scanf('%lld',&n) LL x1=n LL x2=(n+1) if(x1%2==0)// consider more, it will not burst, x1/=2 else x2/=2 ans=x1*x2 for(int i=0i<=32i++) { if(nbreak else ans-=2*ma[i] } printf('%lld ',ans) } }