QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726147 | #9167. Coprime Array | gzy | AC ✓ | 1ms | 3848kb | C++14 | 648b | 2024-11-08 21:56:32 | 2024-11-08 21:56:34 |
Judging History
answer
#include<bits/stdc++.h>
#define gcd __gcd
using namespace std;
using ll = long long;
using db = double;
const int N = 2e5 + 7;
int i, j, k, n, m;
mt19937 rd(time(0));
int main() {
cin >> n >> m;
if(gcd(n, m) == 1) return cout << "1\n" << n,0;
if(n % 2 && !(m % 2)) {
cout << "3\n1 ";
n--;
while(1) {
k = rd() % n + 1;
if(gcd(k, m) == 1 && gcd(n - k, m) == 1) {
cout << k << " " << n - k;
return 0;
}
}
} else {
cout << "2\n";
while(1) {
k = rd() % n + 1;
if(gcd(k, m) == 1 && gcd(n - k, m) == 1) {
cout << k << " " << n - k;
return 0;
}
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
14 34
output:
2 7 7
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1000000000 223092870
output:
2 889059593 110940407
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
2 1000000000
output:
2 1 1
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
649557664 933437700
output:
2 458485727 191071937
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
33396678 777360870
output:
2 11910241 21486437
result:
ok Correct
Test #7:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
48205845 903124530
output:
3 1 22190671 26015173
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
251037078 505905400
output:
2 229283277 21753801
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
30022920 172746860
output:
2 21704673 8318247
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
63639298 808058790
output:
2 45182369 18456929
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
76579017 362768406
output:
3 1 26316649 50262367
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
40423669 121437778
output:
3 1 23555629 16868039
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
449277309 720915195
output:
2 257419886 191857423
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
81665969 919836918
output:
3 1 65790083 15875885
result:
ok Correct
Test #15:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
470578680 280387800
output:
2 408058657 62520023
result:
ok Correct
Test #16:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
58450340 803305503
output:
2 30566740 27883600
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
125896113 323676210
output:
3 1 81950641 43945471
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
381905348 434752500
output:
2 361244479 20660869
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
35787885 270845190
output:
3 1 1123333 34664551
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed