QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722898#9167. Coprime ArrayxielirenWA 0ms3808kbC++14840b2024-11-07 20:32:262024-11-07 20:32:26

Judging History

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

  • [2024-11-07 20:32:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-11-07 20:32:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int read(){
	int s = 0, f = 1;char ch = getchar();
	while(!isdigit(ch)){if(ch == '-')f = -1;ch = getchar();}
	while(isdigit(ch)){s = s * 10 + ch - '0';ch = getchar();}
	return s * f;
}
void write(int x){
    if(x < 0){putchar('-'); x = -x;}
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int main(){
	int n = read(), m = read();
	if(__gcd(n, m) == 1){
		printf("1\n%d", n);
		return 0;
	}	
	if(m % 2 == 0 && n % 2 == 1){
		for(int i = -1;;i --){
			int h = n - i * 2;
			if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
				printf("3\n%d %d %d\n", i, i, h);
				return 0;
			}
		}
	}
	else{
		for(int i = -1;;i --){
			int h = n - i;
			if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
				printf("2\n%d %d\n", i, h);
				return 0;
			}
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3756kb

input:

9 6

output:

3
-1 -1 11

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
-1 15

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
-31 1000000031

result:

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