QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#595843 | #9167. Coprime Array | 336699go# | WA | 0ms | 3648kb | C++17 | 1.4kb | 2024-09-28 14:34:57 | 2024-09-28 14:34:58 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 1e6 + 5, mod = 1e9 + 7, B = 500;
const ll inf = 1e18;
const ld eps = 1e-6;
ll add (ll a, ll b) {
a += b;
if (a < 0) a += mod;
if (a >= mod) a -= mod;
return a;
}
ll mul (ll a, ll b) {
a *= b;
if (a >= mod) a %= mod;
return a;
}
void solve () {
int s, x;
cin >> s >> x;
if (x % 2 == 0 && (s & 1)) {
s--;
for (int i = 1; ; i++) {
if (__gcd(x, i) == 1 && __gcd(s - i, x) == 1) {
cout << "3\n";
cout << 1 << ' ' << i << ' ' << s - i << '\n';
return;
}
}
cout << 1 / 0;
}
if (x % 2 == 0 && s % 2 == 0) {
cout << "2\n";
cout << 1 << ' ' << s - 1 << '\n';
return;
}
for (int i = 1; ; i++) {
if (__gcd(x, i) == 1 && __gcd(s - i, x) == 1) {
cout << "2\n";
cout << i << ' ' << s - i << '\n';
return;
}
}
cout << '\n';
}
bool testcases = 0;
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int test = 1;
if (testcases) cin >> test;
for (int cs = 1; cs <= test; cs++) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3648kb
input:
1000000000 223092870
output:
2 1 999999999
result:
wrong answer Element at position 2 is not coprime to x