/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Wrong Answer 2ms 532.0 KiB
#3 Wrong Answer 7ms 576.0 KiB

Code

/*
 *Copyright (c) Swadheen Islam Robi (SIR01)
 *Created on Thu Sep 05 2024 10:19:08 PM
 */

#include <iostream>
#include <vector>

using namespace std;

int solve(int N, int K) {
    vector<int> A(N, 0);
    int mon = min(K, N);

    for (int i = 0; i < mon; i++) {
        A[i] = 1;
    }

    int X = K - mon;
    for (int i = mon; i < N && X > 0; i++) {
        A[i] = 1;
        X--;
    }

    int Y = 1;
    for (int i = 0; i < N; i++) {
        Y &= A[i];
    }

    return X * Y;
}

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N, K;
        cin >> N >> K;

        int ans = solve(N, K);
        cout << ans << endl;
    }

    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:19:55
Judged At
2024-11-11 02:58:23
Judged By
Score
1
Total Time
7ms
Peak Memory
576.0 KiB