QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549534 | #9167. Coprime Array | ucup-team3519# | AC ✓ | 123ms | 3788kb | C++23 | 1022b | 2024-09-06 17:08:32 | 2024-10-14 07:52:41 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = int64_t;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
i64 s, x;
std::cin >> s >> x;
if (std::gcd(s, x) == 1) {
std::cout << "1\n";
std::cout << s << '\n';
return 0;
}
std::uniform_int_distribution<int> dist(0, x - 1);
bool flag = false;
auto get = [&](i64 s) {
int T = 1e6;
while (T--) {
i64 a = dist(rng), b = s - a;
if (llabs(std::gcd(a, x)) == 1 && llabs(std::gcd(b, x)) == 1) {
flag = true;
return std::make_pair(a, b);
}
}
return std::make_pair(i64(0), i64(0));
};
auto [a, b] = get(s);
if (flag) {
std::cout << "2\n";
std::cout << a << ' ' << b << '\n';
return 0;
}
auto [p, q] = get(s + 1);
assert(flag);
std::cout << "3\n";
std::cout << "-1 " << p << ' ' << q << '\n';
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 17ms
memory: 3784kb
input:
9 6
output:
3 -1 5 5
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
14 34
output:
2 5 9
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
1000000000 223092870
output:
2 135495299 864504701
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 1000000000
output:
2 250805079 -250805077
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
649557664 933437700
output:
2 311821553 337736111
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
33396678 777360870
output:
2 755018621 -721621943
result:
ok Correct
Test #7:
score: 0
Accepted
time: 122ms
memory: 3644kb
input:
48205845 903124530
output:
3 -1 261019757 -212813911
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
251037078 505905400
output:
2 93665009 157372069
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
30022920 172746860
output:
2 119963553 -89940633
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
63639298 808058790
output:
2 119916221 -56276923
result:
ok Correct
Test #11:
score: 0
Accepted
time: 117ms
memory: 3780kb
input:
76579017 362768406
output:
3 -1 242794355 -166215337
result:
ok Correct
Test #12:
score: 0
Accepted
time: 123ms
memory: 3780kb
input:
40423669 121437778
output:
3 -1 59021367 -18597697
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
449277309 720915195
output:
2 458132117 -8854808
result:
ok Correct
Test #14:
score: 0
Accepted
time: 121ms
memory: 3788kb
input:
81665969 919836918
output:
3 -1 604036619 -522370649
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
470578680 280387800
output:
2 162540241 308038439
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
58450340 803305503
output:
2 54248941 4201399
result:
ok Correct
Test #17:
score: 0
Accepted
time: 116ms
memory: 3632kb
input:
125896113 323676210
output:
3 -1 159892157 -33996043
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
381905348 434752500
output:
2 31035337 350870011
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 111ms
memory: 3572kb
input:
35787885 270845190
output:
3 -1 222959567 -187171681
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed