QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#511730 | #9167. Coprime Array | ucup-team3555# | WA | 5ms | 4060kb | C++14 | 712b | 2024-08-10 10:27:58 | 2024-08-10 10:27:59 |
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",x);
return 0;
}
// bool fs=(s%2==0),fx=(x%2==0);
// if(fs&&fx){ // s%2==0 x%2==0
// printf("%d %d",);
// }
std::vector <int> vec(4);
for(int i=-200000;i<=200000;++i){
int a=i,b=s-i;
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(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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5ms
memory: 4060kb
input:
9 6
output:
3 -199991 199999 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
14 34
output:
2 -199999 200013
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3696kb
input:
1000000000 223092870
output:
2 -199999 1000199999
result:
wrong answer Integer element a[2] equals to 1000199999, violates the range [-10^9, 10^9]