QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722906 | #9167. Coprime Array | xieliren | AC ✓ | 0ms | 3880kb | C++14 | 860b | 2024-11-07 20:34:11 | 2024-11-07 20:34:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int read(){
int s = 0, f = 1;char ch = getchar();
while(!isdigit(ch)){if(ch == '-')f = -1;ch = getchar();}
while(isdigit(ch)){s = s * 10 + ch - '0';ch = getchar();}
return s * f;
}
void write(int x){
if(x < 0){putchar('-'); x = -x;}
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
int main(){
int n = read(), m = read();
if(__gcd(n, m) == 1){
printf("1\n%d", n);
return 0;
}
if(m % 2 == 0 && n % 2 == 1){
for(int i = 3e8;;i --){
int h = n - i * 2;
if(__gcd(abs(h), m) == 1 && __gcd(abs(i), m) == 1){
printf("3\n%d %d %d\n", i, i, h);
return 0;
}
}
}
else{
for(int i = 5e8;;i --){
int h = n - i;
if(__gcd(abs(h), m) == 1 && __gcd(abs(i), m) == 1){
printf("2\n%d %d\n", i, h);
return 0;
}
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
9 6
output:
3 299999999 299999999 -599999989
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
14 34
output:
2 499999999 -499999985
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
1000000000 223092870
output:
2 499999979 500000021
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
2 1000000000
output:
2 499999999 -499999997
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
649557664 933437700
output:
2 499999997 149557667
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
33396678 777360870
output:
2 499999999 -466603321
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
48205845 903124530
output:
3 299999999 299999999 -551794153
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
251037078 505905400
output:
2 499999999 -248962921
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
30022920 172746860
output:
2 499999997 -469977077
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
63639298 808058790
output:
2 499999979 -436360681
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
76579017 362768406
output:
3 299999993 299999993 -523420969
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
40423669 121437778
output:
3 299999999 299999999 -559576329
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
449277309 720915195
output:
2 499999996 -50722687
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
81665969 919836918
output:
3 299999993 299999993 -518334017
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
470578680 280387800
output:
2 499999999 -29421319
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
58450340 803305503
output:
2 499999999 -441549659
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
125896113 323676210
output:
3 299999993 299999993 -474103873
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
381905348 434752500
output:
2 499999999 -118094651
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
35787885 270845190
output:
3 299999999 299999999 -564212113
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed