/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 544.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 1ms 332.0 KiB
#5 Accepted 16ms 616.0 KiB
#6 Accepted 13ms 564.0 KiB
#7 Accepted 12ms 564.0 KiB
#8 Accepted 21ms 704.0 KiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-16/3/2024;TIME:-20:13 PM
  BANGALDESH , SYLHET*/
#include<bits/stdc++.h>  
using namespace std;
typedef long long int ll;

int main() {
    int t;
    cin >> t;
    while(t--){
      ll n;
      cin >> n;
      ll game = ((n)*(n-1))/2;
      //cout << game << endl;
      ll num=n-1;
      ll i=0,next=0;
      while(pow(2,i)<=num){
        i++;
      }
      i--;
      next +=pow(2,i);
      while(next > 1){
        next /= 2;
        game =game + next;
        //cout << game << " ";
      }
      cout << game << endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1026 LUFA cup 2024
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-16 14:14:03
Judged At
2024-03-18 05:13:04
Judged By
Score
100
Total Time
21ms
Peak Memory
704.0 KiB