QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#512219 | #9167. Coprime Array | ucup-team956# | AC ✓ | 208ms | 3800kb | C++20 | 1.8kb | 2024-08-10 13:51:52 | 2024-10-14 07:51:55 |
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;
}
// cout << __gcd(-5, 10) << "!!!\n";
for(int i = -1e6; i <= 1e6; i++) {
if(__gcd(abs(i), s) == 1 && __gcd(abs(n - i), s) == 1 && abs(n - i) <= 1e9) {
cout << 2 << "\n";
cout << i << " " << n - i << "\n";
return;
}
}
// if(n != 9 || s != 6) while(1);
for(int i = -500; i <= 500; i++) {
for(int j = -500; j <= 500; j++) {
if(__gcd(abs(i), s) == 1 && __gcd(abs(j), s) == 1 && __gcd(abs(n - i - j), s) == 1 && abs(n - i - j) <= 1e9) {
cout << 3 << "\n";
cout << i << " " << j << " " << n - i - j << "\n";
return;
}
}
}
// for(int i = -50; i <= 50; i++) {
// for(int j = -50; j <= 50; j++) {
// for(int k = -50; k <= 50; k++) {
// if(__gcd(abs(i), s) == 1 && __gcd(abs(j), s) == 1 && __gcd(abs(k), s) == 1 && __gcd(abs(n - i - j - k), s) == 1 && abs(n - i - j - k) <= 1e9) {
// cout << 4 << "\n";
// cout << i << " " << j << " " << k << " " << n - i - j - k << "\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;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 14ms
memory: 3692kb
input:
9 6
output:
3 -499 -499 1007
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
14 34
output:
2 -999999 1000013
result:
ok Correct
Test #3:
score: 0
Accepted
time: 83ms
memory: 3668kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
2 1000000000
output:
2 -999999 1000001
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
649557664 933437700
output:
2 -999979 650557643
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
33396678 777360870
output:
2 -999979 34396657
result:
ok Correct
Test #7:
score: 0
Accepted
time: 172ms
memory: 3732kb
input:
48205845 903124530
output:
3 -499 -499 48206843
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
251037078 505905400
output:
2 -999991 252037069
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
30022920 172746860
output:
2 -999997 31022917
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
63639298 808058790
output:
2 -999979 64639277
result:
ok Correct
Test #11:
score: 0
Accepted
time: 178ms
memory: 3752kb
input:
76579017 362768406
output:
3 -499 -499 76580015
result:
ok Correct
Test #12:
score: 0
Accepted
time: 208ms
memory: 3672kb
input:
40423669 121437778
output:
3 -499 -499 40424667
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
449277309 720915195
output:
2 -999998 450277307
result:
ok Correct
Test #14:
score: 0
Accepted
time: 182ms
memory: 3672kb
input:
81665969 919836918
output:
3 -499 -499 81666967
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
470578680 280387800
output:
2 -999997 471578677
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
58450340 803305503
output:
2 -999998 59450338
result:
ok Correct
Test #17:
score: 0
Accepted
time: 185ms
memory: 3660kb
input:
125896113 323676210
output:
3 -499 -499 125897111
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
381905348 434752500
output:
2 -999989 382905337
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 173ms
memory: 3668kb
input:
35787885 270845190
output:
3 -499 -499 35788883
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed