QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#512080 | #9167. Coprime Array | ucup-team956# | WA | 16ms | 3700kb | C++20 | 1.1kb | 2024-08-10 13:28:00 | 2024-08-10 13:28:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long
int read() {int x;cin>>x;return x;}
void solve() {
int n = read(), s = read();
if(__gcd(n, s) == 1) {
cout << 1 << "\n" << n << "\n";
return;
}
for(int i = -1e6; i <= 1e6; i++) {
if(__gcd(i, s) == 1 && __gcd(n - i, s) == 1) {
cout << 2 << "\n";
cout << i << " " << n - i << "\n";
return;
}
}
for(int i = -1e3; i <= 1e3; i++) {
for(int j = -1e3; j <= 1e3; j++) {
if(__gcd(i, s) == 1 && __gcd(j, s) == 1 && __gcd(n - i - j, s) == 1) {
cout << 3 << "\n";
cout << i << " " << j << " " << n - i - j << "\n";
return;
}
}
}
}
signed main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
#else
//freopen("a.in", "r", stdin);
#endif
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 3700kb
input:
9 6
output:
3 -995 -995 1999
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
14 34
output:
2 -999989 1000003
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
1000000000 223092870
output:
2 -999949 1000999949
result:
wrong answer Integer element a[2] equals to 1000999949, violates the range [-10^9, 10^9]