QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511736#9167. Coprime Arrayucup-team3555#WA 5ms4064kbC++14712b2024-08-10 10:29:332024-08-10 10:29:33

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 10:29:33]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:4064kb
  • [2024-08-10 10:29:33]
  • 提交

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",s);
		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;
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 4064kb

input:

9 6

output:

3
-199991 199999 1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
-199999 200013

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
-199999 1000199999

result:

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