QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#524303 | #9167. Coprime Array | zhoukangyang# | AC ✓ | 0ms | 3732kb | C++14 | 1.4kb | 2024-08-19 15:20:13 | 2024-08-19 15:20:14 |
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 < s; ++v) {
if(__gcd(v, x) == 1 && __gcd(s - v, x) == 1) {
cout << 2 << '\n' << v << ' ' << s - v << '\n';
return;
}
}
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 = u; u + v < s; ++v) if(__gcd(v, x) == 1) {
if(__gcd(s - u - v, x) == 1) {
cout << 3 << '\n' << u << ' ' << v << ' ' << s - u - v << '\n';
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;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 1000000000
output:
2 1 1
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
649557664 933437700
output:
2 11 649557653
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
33396678 777360870
output:
2 1 33396677
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
48205845 903124530
output:
3 1 31 48205813
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
251037078 505905400
output:
2 1 251037077
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
30022920 172746860
output:
2 1 30022919
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
63639298 808058790
output:
2 29 63639269
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
76579017 362768406
output:
3 1 1 76579015
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
40423669 121437778
output:
3 1 1 40423667
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
449277309 720915195
output:
2 1 449277308
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
81665969 919836918
output:
3 1 5 81665963
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
470578680 280387800
output:
2 1 470578679
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
58450340 803305503
output:
2 1 58450339
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
125896113 323676210
output:
3 1 31 125896081
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
381905348 434752500
output:
2 1 381905347
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
35787885 270845190
output:
3 1 1 35787883
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed