/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Accepted 2ms 320.0 KiB
#5 Accepted 2ms 580.0 KiB
#6 Accepted 5ms 576.0 KiB
#7 Accepted 34ms 1.891 MiB
#8 Accepted 32ms 1.441 MiB
#9 Accepted 34ms 1.641 MiB
#10 Accepted 35ms 2.234 MiB
#11 Accepted 34ms 2.172 MiB

Code

/**
 *  Author: AhSaN (JUST-22)
 *  Created: 06-09-2024  07:44:28
**/
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void Sol(int Cs) {
  long long n, k;
  cin >> n >> k;
  long long hi = k / n, lo = 0, res = 0;
  while (hi >= lo) {
    long long mid = (hi + lo) >> 1;
    long long L = mid * n;
    long long R = k - (mid * n);
    if (R >= L) {
      res = max(res, mid * R);
      lo = mid + 1;
    } else {
      res = max(res, mid * R);
      hi = mid - 1;
    }
  }
  cout << res << "\n";
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int Tc = 1;
  cin >> Tc;
  for (int Cs = 1; Cs <= Tc; Cs++) {
    Sol(Cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-06 02:53:06
Judged At
2024-11-11 02:57:01
Judged By
Score
100
Total Time
35ms
Peak Memory
2.234 MiB