QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#722886#9167. Coprime ArrayguanzyWA 0ms3748kbC++14451b2024-11-07 20:30:032024-11-07 20:30:04

Judging History

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

  • [2024-11-07 20:30:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2024-11-07 20:30:03]
  • 提交

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