April Long One 2022

Ezio and Guards

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int x, y;
        cin >> x >> y;
        if (x >= y) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

The Cooler Dilemma 1

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int x, y, z;
        cin >> x >> y >> z;
        if (x * z < y)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

The Cooler Dilemma 2

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int a, b;
        cin >> a >> b;
        if (b % a == 0) {
            int p = b / a - 1;
            if (p < 0) {
                cout << 0 << endl;
            } else {
                cout << p << endl;
            }
        } else {
            int p = b / a;
            cout << p << endl;
        }
    }
    return 0;
}

Dazzling GCD Pair

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long a, b, i = -1;
        cin >> a >> b;
        if (a % 2 == 0) {
            if (a + 2 <= b)
                cout << a << " " << a + 2;
            else
                cout << i;
        } else if (a % 3 == 0) {
            if (a + 3 <= b)
                cout << a << " " << a + 3;
            else
                cout << i;
        } else {
            if (a + 3 <= b)
                cout << a + 1 << " " << a + 3;
            else
                cout << i;
        }
        cout << endl;
    }
    return 0;
}

Dazzling AXNODR Challenge

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long n, result = 0;
        cin >> n;
        if (n % 2 == 0)  // even - bitwise XOR
        {
            if (n % 4 == 0)
                result = 3 ^ n;
            else
                result = 3;
        } else  // odd - bitwise AND
        {
            if ((n - 1) % 4 == 0)
                result = (3 ^ (n - 1)) & n;
            else
                result = 3;
        }
        cout << result << endl;
    }
    return 0;
}

Prime Sum

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long a, b, result;
        cin >> a >> b;
        if (a == 1 || b == 1)
            result = -1;
        else if (__gcd(a, b) == 1)
            result = 1;
        else
            result = 0;

        cout << result << endl;
    }
    return 0;
}

Pairwise Xors

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long x;
        cin >> x;
        long long a = x & -(x - 1);
        if (x & 1 || x == a) {
            cout << -1 << endl;
        } else {
            cout << a / 2 << " " << x / 2 << " " << (x - a) / 2 << endl;
        }
    }
    return 0;
}

Last updated

Was this helpful?