QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#535669 | #9167. Coprime Array | ucup-team1264 | AC ✓ | 800ms | 3772kb | C++20 | 1.3kb | 2024-08-28 12:36:33 | 2024-08-28 12:36:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
#define int i64
void solve() {
int s, x; cin >> s >> x;
if (gcd(s, x) == 1) {
cout << 1 << "\n";
cout << s << "\n";
return;
}
{
auto time = chrono::high_resolution_clock::now();
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using chrono_literals::operator""ms;
while (chrono::high_resolution_clock::now() - time < 800ms) {
int t = rng() % int(1e9 - 7) + 1;
if (gcd(t, x) == 1 && gcd(s - t, x) == 1) {
cout << 2 << "\n";
cout << t << " " << s - t << "\n";
return;
}
}
while (true) {
int t1 = 1, t2 = rng() % (x - 1) + 1;
if (gcd(t2, x) == 1 && gcd(s - t1 - t2, x) == 1) {
cout << 3 << "\n";
cout << 1 << " " << t2 << " " << s - t1 - t2 << "\n";
return;
}
}
}
}
#undef int
// Make bold hypotheses and verify carefully
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 800ms
memory: 3712kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
14 34
output:
2 695449845 -695449831
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1000000000 223092870
output:
2 713909297 286090703
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
2 1000000000
output:
2 767514793 -767514791
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
649557664 933437700
output:
2 366950723 282606941
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
33396678 777360870
output:
2 661572997 -628176319
result:
ok Correct
Test #7:
score: 0
Accepted
time: 796ms
memory: 3620kb
input:
48205845 903124530
output:
3 1 201329281 -153123437
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
251037078 505905400
output:
2 919202659 -668165581
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
30022920 172746860
output:
2 408127437 -378104517
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
63639298 808058790
output:
2 465311897 -401672599
result:
ok Correct
Test #11:
score: 0
Accepted
time: 797ms
memory: 3636kb
input:
76579017 362768406
output:
3 1 329789287 -253210271
result:
ok Correct
Test #12:
score: 0
Accepted
time: 797ms
memory: 3588kb
input:
40423669 121437778
output:
3 1 65663723 -25240055
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
449277309 720915195
output:
2 246449848 202827461
result:
ok Correct
Test #14:
score: 0
Accepted
time: 800ms
memory: 3704kb
input:
81665969 919836918
output:
3 1 750963407 -669297439
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
470578680 280387800
output:
2 565900493 -95321813
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
58450340 803305503
output:
2 861874912 -803424572
result:
ok Correct
Test #17:
score: 0
Accepted
time: 800ms
memory: 3636kb
input:
125896113 323676210
output:
3 1 73074583 52821529
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
381905348 434752500
output:
2 940206541 -558301193
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 800ms
memory: 3648kb
input:
35787885 270845190
output:
3 1 153795727 -118007843
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed