QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522219 | #9167. Coprime Array | qwqwf# | AC ✓ | 0ms | 3736kb | C++14 | 1.0kb | 2024-08-16 19:48:02 | 2024-08-16 19:48:02 |
Judging History
answer
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
//#pragma GCC optimize("Ofast","unroll-loops","inline")
#include<bits/stdc++.h>
#define ll long long
//#define int ll
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int N=5e5+10,M=1e6+10,mod=998244353;
const int Inf=1e9;
int s,x;
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>s>>x;
if(__gcd(s,x)==1) return cout<<1<<'\n'<<s<<'\n',0;
if(x%2==0&&s%2==1){
cout<<3<<'\n';
for(int i=1;;i+=2) if(__gcd(i,x)==1){
if(__gcd(s+2*i,x)==1&&abs(s+2*i)<=Inf) return cout<<-i<<' '<<-i<<' '<<s+2*i<<'\n',0;
if(__gcd(s-2*i,x)==1&&abs(s-2*i)<=Inf) return cout<<i<<' '<<i<<' '<<s-2*i<<'\n',0;
}
return 0;
}
cout<<2<<'\n';
for(int i=1;;i+=2) if(__gcd(i,x)==1){
if(__gcd(s+i,x)==1&&abs(s+i)<=Inf) return cout<<-i<<' '<<s+i<<'\n',0;
if(__gcd(s-i,x)==1&&abs(s-i)<=Inf) return cout<<i<<' '<<s-i<<'\n',0;
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
9 6
output:
3 -1 -1 11
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
14 34
output:
2 -1 15
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
2 1000000000
output:
2 -1 3
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
649557664 933437700
output:
2 -7 649557671
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
33396678 777360870
output:
2 -1 33396679
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
48205845 903124530
output:
3 -1 -1 48205847
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
251037078 505905400
output:
2 -1 251037079
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
30022920 172746860
output:
2 -1 30022921
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
63639298 808058790
output:
2 -1 63639299
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
76579017 362768406
output:
3 1 1 76579015
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
40423669 121437778
output:
3 -1 -1 40423671
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
449277309 720915195
output:
2 1 449277308
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
81665969 919836918
output:
3 -1 -1 81665971
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
470578680 280387800
output:
2 -1 470578681
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
58450340 803305503
output:
2 1 58450339
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
125896113 323676210
output:
3 -7 -7 125896127
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3684kb
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