Accepted
Code
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
//ofstream file("output0.txt");
void solve()
{
ll n; cin>>n;
ll k=1,ans=0;
while(k*2 < n) k*=2;
ans = (n*(n-1))/2;
while(k)
{
ans += (k/2);
k=k/2;
}
cout<<ans<<endl;
//file<<ans<<endl;
}
int main()
{
int t; cin>>t; while(t--) solve();
//file.close();
}
Information
- Submit By
- Type
- Submission
- Problem
- P1026 LUFA cup 2024
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-01-14 09:18:57
- Judged At
- 2024-11-11 03:43:32
- Judged By
- Score
- 100
- Total Time
- 26ms
- Peak Memory
- 588.0 KiB