QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#722871#9167. Coprime ArrayguanzyWA 0ms3796kbC++14451b2024-11-07 20:28:342024-11-07 20:28:34

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 20:28:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-11-07 20:28:34]
  • 提交

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: 3792kb

input:

9 6

output:

3
11 -1 -1

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

14 34

output:

2
15 -1

result:

ok Correct

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3744kb

input:

1000000000 223092870

output:

2
1000000031 -31

result:

wrong answer Integer element a[1] equals to 1000000031, violates the range [-10^9, 10^9]