QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#722904#9167. Coprime ArrayxielirenTL 0ms0kbC++14842b2024-11-07 20:33:172024-11-07 20:33:17

Judging History

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

  • [2024-11-07 20:33:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-07 20:33:17]
  • 提交

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 = 3e8;;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 = 5e8;;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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

9 6

output:


result: