/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 4ms 328.0 KiB
#4 Accepted 2ms 332.0 KiB
#5 Accepted 25ms 556.0 KiB
#6 Accepted 21ms 576.0 KiB
#7 Accepted 19ms 560.0 KiB
#8 Accepted 35ms 688.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

long long findpower(long long y)
{
    long long x = floor(log2(y-1));
    return x;
}

void sir()
{
    long long n;
    cin>>n;
    if(n==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
        long long x = findpower(n); //after qualifier, 2^x teams for knockout.
        long long match = n*(n-1)/2; // first round.
        for(long long i=x; i>=1; i--)
        {   
            n = pow(2,i); //new team every round.
            match += n/2 ;
        }
        cout<<match<<endl;
    }
    
}

int main()
{
    long long t;
    cin>>t;
    while(t--)
    {
        sir();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1026 LUFA cup 2024
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-12 19:54:20
Judged At
2024-11-11 03:40:53
Judged By
Score
100
Total Time
35ms
Peak Memory
688.0 KiB