/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 2ms 580.0 KiB
#6 Accepted 4ms 532.0 KiB
#7 Accepted 28ms 1.77 MiB
#8 Accepted 26ms 1.676 MiB
#9 Accepted 54ms 1.766 MiB
#10 Accepted 57ms 2.223 MiB
#11 Accepted 26ms 1.969 MiB

Code

#include <bits/stdc++.h>
 
using namespace std;
 
// Macros
#define REP(i, j, n) for(int i = j; i < n; i++)
#define trav(i, a) for(auto i: a)
#define all(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define GCD __gcd
 
// Type Names
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

// Global Variables
const int MOD = 1e9 + 7;

// custom hash
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// print vector X)
template <typename T>
void print_vector(vector<T> a){
    int n = a.size();
    for (int i = 0; i < n; i++){
        cout << a[i] << (i == n - 1 ? "\n" : " ");
    }
}

template <typename T>
void print_2d_vector(vector<vector<T>> a){
    int row = a.size();
    int col = a[0].size();
    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
}

template <typename T>
void print_stack(stack<T> st){
    while (!st.empty()){
        cout << st.top() << " ";
        st.pop();
    }
    cout << "\n";
}

template <typename T>
void print_set(set<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

template <typename T>
void print_set(multiset<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

string int_to_bin(ll n){
    string ans = "";
    while (n) {
        ans = to_string(n % 2) + ans;
        n /= 2;
    }
    return ans;
}

ull bin_to_int(string s){
    bitset<20> bin(s);
    return bin.to_ulong();
}

ll res (ll n, ll k, ll y){
    return y * (k - (n * y));
}

void solve()
{   
    ll n, k;
    cin >> n >> k;
    ll y1 = ceil((k / (2.0 * n)));
    ll y2 = floor((k / (2.0 * n)));
    cout << max(0ll, max(res(n, k, y1), res(n, k, y2))) << "\n";
}

 
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("breedflip.in", "r", stdin);
    // freopen("breedflip.out", "w", stdout);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    solve();
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Contest
Brain Booster #5
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 17:23:03
Judged At
2024-09-05 17:23:03
Judged By
Score
100
Total Time
57ms
Peak Memory
2.223 MiB