QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#784616 | #9799. Magical Palette | ucup-team3519# | WA | 43ms | 6996kb | C++17 | 896b | 2024-11-26 15:31:52 | 2024-11-26 15:32:02 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = int64_t;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
void solve() {
int n, m;
std::cin >> n >> m;
if (gcd(n, m) != 1) {
std::cout << "No\n";
return;
}
const int p = n * m;
std::vector<int> a(n), b(m);
a[0] = 1 % p;
for (int i = 1; i < n; ++i) {
a[i] = (i64)a[i - 1] * (m + 1) % p;
}
for (int i = 0; i < m; ++i) {
b[i] = ((i64)i * n + 1) % p;
}
std::cout << "Yes\n";
std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << '\n';
std::copy(b.begin(), b.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 2 3 2 2
output:
Yes 1 4 1 3 5 No
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 42ms
memory: 6996kb
input:
1 1 1000000
output:
Yes 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
result:
ok 1 cases (1 test case)
Test #3:
score: -100
Wrong Answer
time: 43ms
memory: 6988kb
input:
1 1000000 1
output:
Yes 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 48576 97152 194304 388608 777216 554432 108864 217728 435456 870912 741824 483648 967296 934592 869184 738368 476736 953472 906944 813888 627776 255552 511104 22208 44416 88832 177664 355328 710656 421312 842...
result:
wrong answer Duplicated Color 64 (test case 1)