QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524301 | #9167. Coprime Array | zhoukangyang# | WA | 0ms | 3664kb | C++14 | 1.0kb | 2024-08-19 15:15:00 | 2024-08-19 15:15:01 |
Judging History
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]