QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#519038#9167. Coprime ArrayWWWWJLWA 0ms3800kbC++14714b2024-08-14 15:37:592024-08-14 15:37:59

Judging History

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

  • [2024-08-14 15:37:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3800kb
  • [2024-08-14 15:37:59]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

mt19937 rd(time(NULL));

int gcd(int a,int b){
	return b == 0 ? a : gcd(b,a % b);
}

void solve(){
	int n,m;
	cin >> n >> m;
	if(gcd(n,m) == 1){
		cout << 1 <<"\n";
		cout << n <<"\n";
		return;
	}
	if((n % 2 == 1) && (m % 2 == 0)){
		cout << 3 <<"\n";
		n -= 1;
		cout << 1 << " ";
	}else{
		cout << 2 <<"\n";
	}
	while(1){
		int x = rd() % n;
		int y = n - x;
		if(gcd(x,n) == 1 && gcd(y,n) == 1){
			cout << x << " " << y <<"\n";
			return;
		}
	}
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t --){
    	solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3800kb

input:

9 6

output:

3
1 3 5

result:

wrong answer Element at position 2 is not coprime to x