QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#511743 | #9167. Coprime Array | ucup-team3555# | AC ✓ | 61ms | 4096kb | C++14 | 703b | 2024-08-10 10:33:11 | 2024-10-14 07:51:46 |
Judging History
answer
# include <bits/stdc++.h>
inline int gcd(int a,int b){
return (!b)?a:gcd(b,a%b);
}
int main(void){
int s,x;
std::cin>>s>>x;
int g=gcd(s,x);
if(g==1){
printf("1\n%d",s);
return 0;
}
std::vector <int> vec(4);
for(int i=-200000;i<=200000;++i){
int a=i,b=s-i;
if(abs(a)>1e9||abs(b)>1e9) continue;
if(gcd(abs(a),x)==1&&gcd(abs(b),x)==1){
printf("2\n%d %d",a,b);
exit(0);
}
a=s-i-1,b=i;
if(abs(a)>1e9||abs(b)>1e9) continue;
if(gcd(abs(a),x)==1&&gcd(abs(b),x)==1){
vec.resize(3);
vec[0]=a,vec[1]=b,vec[2]=1;
}
}
assert(vec.size()==3);
printf("3\n%d %d %d",vec[0],vec[1],vec[2]);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 5ms
memory: 3812kb
input:
9 6
output:
3 -199991 199999 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
14 34
output:
2 -199999 200013
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 4032kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 1000000000
output:
2 -199999 200001
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
649557664 933437700
output:
2 -199993 649757657
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
33396678 777360870
output:
2 -199999 33596677
result:
ok Correct
Test #7:
score: 0
Accepted
time: 58ms
memory: 3740kb
input:
48205845 903124530
output:
3 48005851 199993 1
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
251037078 505905400
output:
2 -199993 251237071
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
30022920 172746860
output:
2 -199999 30222919
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 4096kb
input:
63639298 808058790
output:
2 -199993 63839291
result:
ok Correct
Test #11:
score: 0
Accepted
time: 61ms
memory: 3740kb
input:
76579017 362768406
output:
3 76379029 199987 1
result:
ok Correct
Test #12:
score: 0
Accepted
time: 58ms
memory: 3732kb
input:
40423669 121437778
output:
3 40223669 199999 1
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
449277309 720915195
output:
2 -199993 449477302
result:
ok Correct
Test #14:
score: 0
Accepted
time: 59ms
memory: 3740kb
input:
81665969 919836918
output:
3 81465983 199985 1
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
470578680 280387800
output:
2 -199993 470778673
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
58450340 803305503
output:
2 -199985 58650325
result:
ok Correct
Test #17:
score: 0
Accepted
time: 57ms
memory: 3780kb
input:
125896113 323676210
output:
3 125696113 199999 1
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
381905348 434752500
output:
2 -199961 382105309
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: 58ms
memory: 4028kb
input:
35787885 270845190
output:
3 35587891 199993 1
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed