Submission #52657732
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) static_cast<int>((x).size())
#define int long long
typedef long long ll;
int power(int a, int b) {
int res = 1;
for (; b; b /= 2, a = a * a % 10) {
if (b & 1) res = res * a % 10;
}
return res;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m, k;
cin >> n >> m >> k;
if (n < m) {
cout << power(2, n) << "\n";
continue;
}
int cyc = m - k;
if (cyc == 1) cout << 0 << "\n";
else cout << power(2, (n - m) % cyc + k) << "\n";
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Simple Math 4 |
| User | MridulAhi |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 889 Byte |
| Status | AC |
| Exec Time | 57 ms |
| Memory | 3536 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3524 KiB |
| test_00.txt | AC | 57 ms | 3452 KiB |
| test_01.txt | AC | 57 ms | 3392 KiB |
| test_02.txt | AC | 57 ms | 3468 KiB |
| test_03.txt | AC | 22 ms | 3416 KiB |
| test_04.txt | AC | 22 ms | 3380 KiB |
| test_05.txt | AC | 22 ms | 3536 KiB |
| test_06.txt | AC | 43 ms | 3348 KiB |
| test_07.txt | AC | 43 ms | 3428 KiB |