QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#513730 | #9167. Coprime Array | ucup-team3734# | WA | 0ms | 3708kb | C++23 | 800b | 2024-08-10 19:20:56 | 2024-08-10 19:20:57 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(), (x).end()
ll gcd(ll x, ll y) {
while (x) {
y %= x;
swap(x, y);
}
return x + y;
}
int main() {
ios_base::sync_with_stdio(false);
ll s, x;
cin >> s >> x;
if (gcd(s, x) == 1) {
cout << "1\n" << s << "\n";
return 0;
}
if (x % 2 == 0 && s % 2 == 1) { // 3
cout << "3\n";
for (ll k = 0; ; ++k)
if (gcd(k, x) == 1 && gcd(s + 1 + k, x) == 1) {
cout << s + k + 1 << " " << (-k) << " -1\n";
return 0;
}
} else {
for (ll k = 0; ; ++k) {
if (gcd(k, x) == 1 && gcd(s + k, x) == 1) {
cout << "2\n";
cout << s + k << " " << (-k) << "\n";
return 0;
}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
9 6
output:
3 11 -1 -1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
14 34
output:
2 15 -1
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
1000000000 223092870
output:
2 1000000031 -31
result:
wrong answer Integer element a[1] equals to 1000000031, violates the range [-10^9, 10^9]