/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 328.0 KiB
#2 Accepted 3ms 488.0 KiB
#3 Accepted 3ms 484.0 KiB
#4 Accepted 3ms 564.0 KiB
#5 Accepted 3ms 772.0 KiB
#6 Accepted 9ms 696.0 KiB
#7 Accepted 65ms 1.883 MiB
#8 Accepted 57ms 1.535 MiB
#9 Accepted 69ms 1.871 MiB
#10 Accepted 58ms 2.348 MiB
#11 Accepted 68ms 2.164 MiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
        Too_Many_Jobs {
            int n, k;
            cin >> n >> k;
            if (n >= k) {
                cout << 0 << nl;
                goto hell;
            }
            int L = 1, H = k, mid, ans = 0;
            while (L <= H) {
                mid = (L + H) >> 1;
                if (1 + (mid * n) > k) {
                    H = mid - 1;
                }
                else {
                    ans = mid;
                    L = mid + 1;
                }
            }
            int x = (k - (ans * n)), y = ans;
            dbg(x, y);
            ans = x * y;
            y = (y + 1) / 2;
            x = k - y * n;
            dbg(x, y);
            ans = max(x * y, ans);
            cout << ans << nl;
        }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 17:01:21
Judged At
2024-11-11 02:58:58
Judged By
Score
100
Total Time
69ms
Peak Memory
2.348 MiB