QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#521699 | #9167. Coprime Array | hhu_yjh | AC ✓ | 184ms | 3720kb | C++17 | 1.6kb | 2024-08-16 14:01:41 | 2024-08-16 14:01:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
const int mod=998244353;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<ll,ll> PII;
ll n,k;
int dp[1000+10][1000+10];
int a[N];
void solve(){
int s,x;
cin>>s>>x;
if(__gcd(s,x)==1){
cout<<1<<endl;
cout<<s<<endl;
return;
}
// for(int i=s-1;i>=s-1000000;i--){
// cout<<2<<endl;
// cout<<i<<' '<<s-i<<endl;
// return;
// }
for(int i=s-1000000;i<=s+1000000;i++){
if((__gcd(abs(i),x)==1)&&__gcd(abs(s-i),x)==1){
cout<<2<<endl;
cout<<i<<' '<<s-i<<endl;
return;
}
}
for(int i=s-1;i>=s-10000;i--){
if(__gcd(abs(i),x)!=1) continue;
for(int j=i-1000;j<=i+1000;j++){
if(__gcd(abs(j),x)!=1) continue;
if(__gcd(abs(s-(i+j)),x)==1){
cout<<3<<endl;
cout<<i<<' '<<j<<' '<<s-(i+j)<<endl;
return;
}
}
}
for(int i=s+1;i<=s+10000;i++){
if(__gcd(abs(i),x)!=1) continue;
for(int j=i-1000;j<=i+1000;j++){
if(__gcd(abs(j),x)!=1) continue;
if(__gcd(abs(s-(i+j)),x)==1){
cout<<3<<endl;
cout<<i<<' '<<j<<' '<<s-(i+j)<<endl;
return;
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--){
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 11ms
memory: 3580kb
input:
9 6
output:
3 7 -989 991
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
14 34
output:
2 -999985 999999
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
1000000000 223092870
output:
2 999000017 999983
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
2 1000000000
output:
2 -999997 999999
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
649557664 933437700
output:
2 648557681 999983
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
33396678 777360870
output:
2 32396681 999997
result:
ok Correct
Test #7:
score: 0
Accepted
time: 164ms
memory: 3712kb
input:
48205845 903124530
output:
3 48205841 48204851 -48204847
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
251037078 505905400
output:
2 250037087 999991
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
30022920 172746860
output:
2 29022923 999997
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
63639298 808058790
output:
2 62639351 999947
result:
ok Correct
Test #11:
score: 0
Accepted
time: 172ms
memory: 3588kb
input:
76579017 362768406
output:
3 76579015 76578025 -76578023
result:
ok Correct
Test #12:
score: 0
Accepted
time: 169ms
memory: 3588kb
input:
40423669 121437778
output:
3 40423667 40422667 -40422665
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
449277309 720915195
output:
2 448277311 999998
result:
ok Correct
Test #14:
score: 0
Accepted
time: 170ms
memory: 3664kb
input:
81665969 919836918
output:
3 81665965 81664967 -81664963
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
470578680 280387800
output:
2 469578691 999989
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
58450340 803305503
output:
2 57450340 1000000
result:
ok Correct
Test #17:
score: 0
Accepted
time: 184ms
memory: 3620kb
input:
125896113 323676210
output:
3 125896103 125895113 -125895103
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
381905348 434752500
output:
2 380905351 999997
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 164ms
memory: 3592kb
input:
35787885 270845190
output:
3 35787883 35786911 -35786909
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed