Submission #53178645


Source Code Expand

/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        ll n, a, b;
        cin >> n >> a >> b;
        if (b > n) {
            cout << (1 << ((n - 1) % 4 + 1)) % 10 << "\n";
            continue;
        }
        if (a == b + 1) {
            cout << 0 << "\n";
            continue;
        }
        ll e = (((n - b) % (a - b)) + b);
        if (e == 0) {
            cout << 1 << "\n";
        } else {
            cout << (1 << ((e - 1) % 4 + 1)) % 10 << "\n";
        }
    }

    return 0;
}

Submission Info

Submission Time
Task B - Simple Math 4
User atodo
Language C++ 20 (gcc 12.2)
Score 400
Code Size 797 Byte
Status AC
Exec Time 30 ms
Memory 3564 KiB

Judge Result

Set Name Sample All after_contest
Score / Max Score 0 / 0 400 / 400 0 / 0
Status
AC × 1
AC × 9
AC × 1
Set Name Test Cases
Sample example_00.txt
All example_00.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt
after_contest after_contest_00.txt
Case Name Status Exec Time Memory
after_contest_00.txt AC 29 ms 3492 KiB
example_00.txt AC 1 ms 3536 KiB
test_00.txt AC 30 ms 3440 KiB
test_01.txt AC 29 ms 3440 KiB
test_02.txt AC 29 ms 3484 KiB
test_03.txt AC 19 ms 3492 KiB
test_04.txt AC 19 ms 3484 KiB
test_05.txt AC 19 ms 3488 KiB
test_06.txt AC 29 ms 3556 KiB
test_07.txt AC 30 ms 3564 KiB