QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#516657 | #9167. Coprime Array | SGColin | AC ✓ | 7ms | 3944kb | C++17 | 955b | 2024-08-12 20:10:35 | 2024-08-12 20:10:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
inline int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
int main() {
int s = rd(), x = rd();
if (gcd(s, x) == 1) {printf("1\n%d", s); return 0;}
rep(i, 1, 100000) {
int a = i, b = s - a;
if (gcd(a, x) == 1 && gcd(abs(b), x) == 1) {
printf("2\n%d %d", a, b); return 0;
}
}
rep(i, 1, 100000) {
int a = i, b = s - a - 1;
if (gcd(a, x) == 1 && gcd(abs(b), x) == 1) {
printf("3\n%d %d %d", a, b, 1); return 0;
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3812kb
input:
9 6
output:
3 1 7 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
2 1000000000
output:
2 1 1
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
649557664 933437700
output:
2 11 649557653
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
33396678 777360870
output:
2 1 33396677
result:
ok Correct
Test #7:
score: 0
Accepted
time: 7ms
memory: 3808kb
input:
48205845 903124530
output:
3 31 48205813 1
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
251037078 505905400
output:
2 1 251037077
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
30022920 172746860
output:
2 1 30022919
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
63639298 808058790
output:
2 29 63639269
result:
ok Correct
Test #11:
score: 0
Accepted
time: 3ms
memory: 3876kb
input:
76579017 362768406
output:
3 1 76579015 1
result:
ok Correct
Test #12:
score: 0
Accepted
time: 7ms
memory: 3684kb
input:
40423669 121437778
output:
3 1 40423667 1
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
449277309 720915195
output:
2 1 449277308
result:
ok Correct
Test #14:
score: 0
Accepted
time: 7ms
memory: 3744kb
input:
81665969 919836918
output:
3 5 81665963 1
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
470578680 280387800
output:
2 1 470578679
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
58450340 803305503
output:
2 1 58450339
result:
ok Correct
Test #17:
score: 0
Accepted
time: 3ms
memory: 3752kb
input:
125896113 323676210
output:
3 31 125896081 1
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
381905348 434752500
output:
2 1 381905347
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 6ms
memory: 3744kb
input:
35787885 270845190
output:
3 1 35787883 1
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed