QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#722886 | #9167. Coprime Array | guanzy | WA | 0ms | 3748kb | C++14 | 451b | 2024-11-07 20:30:03 | 2024-11-07 20:30:04 |
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,s-k);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
9 6
output:
3 7 1 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
14 34
output:
2 13 1
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3740kb
input:
1000000000 223092870
output:
2 999999997 3
result:
wrong answer Element at position 2 is not coprime to x