/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 408.0 KiB
#3 Accepted 4ms 548.0 KiB
#4 Accepted 2ms 532.0 KiB
#5 Accepted 24ms 568.0 KiB
#6 Accepted 22ms 552.0 KiB
#7 Accepted 21ms 560.0 KiB
#8 Accepted 26ms 588.0 KiB

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