QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524301#9167. Coprime Arrayzhoukangyang#WA 0ms3664kbC++141.0kb2024-08-19 15:15:002024-08-19 15:15:01

Judging History

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

  • [2024-08-19 15:15:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-08-19 15:15:00]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long 
#define sz(a) ((int) (a).size())
#define pb emplace_back
#define me(a, x) memset(a, x, sizeof(a))
#define vi vector<int>
using namespace std;
const int N = 1 << 16, M = 16, mod = 998244353;
ll s, x;
void Main() {
	cin >> s >> x;
	if(__gcd(s, x) == 1) {
		cout << "1\n" << s << '\n';
		return;
	}
	if(x % 2 == 1 || s % 2 == 0) {
		for(ll v = 1; v; ++v) {
			if(__gcd(v, x) == 1 && __gcd(v + s, x) == 1) {
				cout << 2 << '\n' << -v << ' ' << v + s << '\n';
				return;
			}
		}
		return;
	}
	for(ll u = 1; u; ++u) if(__gcd(u, x) == 1) {
		for(ll v = 1; v <= u; ++v) if(__gcd(v, x) == 1) {
			if(__gcd(u + v + s, x) == 1) {
				cout << 3 << '\n' << u + v + s << ' ' << -u << ' ' << -v << '\n';
				return;
			}
		}
	}
}
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t; cin >> t; while(t--) 
	Main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
11 -1 -1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
-1 15

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
-31 1000000031

result:

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