QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#509299 | #9167. Coprime Array | PhantomThreshold# | AC ✓ | 1ms | 3724kb | C++17 | 838b | 2024-08-08 13:26:55 | 2024-10-14 07:51:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll lim=1000000;
const ll bound=1000000000;
int main(){
ios_base::sync_with_stdio(false);
ll s,x;
cin >> s >> x;
if (__gcd(s,x)==1){
cout << 1 << "\n";
cout << s << "\n";
return 0;
}
if (s%2==0 || x%2==1){
for (ll a=-lim;a<=lim;a++){
ll b=s-a;
if (abs(a)>bound || abs(b)>bound) continue;
if (__gcd(abs(a),abs(x))==1 && __gcd(abs(b),abs(x))==1){
cout << 2 << "\n";
cout << a << " " << b << "\n";
return 0;
}
}
}
else{
for (ll a=-lim;a<=lim;a++){
ll b=s-1-a;
if (abs(a)>bound || abs(b)>bound) continue;
if (__gcd(abs(a),abs(x))==1 && __gcd(abs(b),abs(x))==1){
cout << 3 << "\n";
cout << 1 << " " << a << " " << b << "\n";
return 0;
}
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
9 6
output:
3 1 -999995 1000003
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
14 34
output:
2 -999999 1000013
result:
ok Correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 1000000000
output:
2 -999999 1000001
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
649557664 933437700
output:
2 -999979 650557643
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
33396678 777360870
output:
2 -999979 34396657
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
48205845 903124530
output:
3 1 -999959 49205803
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
251037078 505905400
output:
2 -999991 252037069
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
30022920 172746860
output:
2 -999997 31022917
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
63639298 808058790
output:
2 -999979 64639277
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
76579017 362768406
output:
3 1 -999995 77579011
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
40423669 121437778
output:
3 1 -999997 41423665
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
449277309 720915195
output:
2 -999998 450277307
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
81665969 919836918
output:
3 1 -999997 82665965
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
470578680 280387800
output:
2 -999997 471578677
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
58450340 803305503
output:
2 -999998 59450338
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
125896113 323676210
output:
3 1 -999971 126896083
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
381905348 434752500
output:
2 -999989 382905337
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
35787885 270845190
output:
3 1 -999983 36787867
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed