QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#722866 | #9167. Coprime Array | guanzy | WA | 0ms | 3816kb | C++14 | 451b | 2024-11-07 20:27:10 | 2024-11-07 20:27:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int s,x;
int gcd(int a,int b){
return !b?a:gcd(b,a%b);
}
int main(){
cin>>s>>x;
if(gcd(s,x)==1){
printf("1\n%d",s);
}else if(x%2==0&&s%2==1){
printf("3\n");
int k=s+2;
while(gcd(k,x)>1||gcd((k-s)/2,x)>1) k+=2;
printf("%d %d %d",-k,(k-s)/2,(k-s)/2);
}else{
printf("2\n");
int k=s+1;
while(gcd(k,x)>1||gcd(k-s,x)>1) k++;
printf("%d %d",-k,k-s);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
9 6
output:
3 -11 1 1
result:
wrong answer Sum of the elements is not equal to s