QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768420 | #9167. Coprime Array | ucup-team4352# | TL | 0ms | 3676kb | C++23 | 1.0kb | 2024-11-21 10:22:33 | 2024-11-21 10:22:33 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define log(x) (31^__builtin_clz(x))
#define lowbit(x) (x&-x)
#define pii pair<int,int>
using namespace std;
bool check(ll x,ll y){
return __gcd(abs(x),abs(y))==1;
}
void solve(){
ll s,x;
cin>>s>>x;
if(check(s,x)){
cout<<"1\n"<<s<<"\n";
return;
}
for(int i=1;i<=x;i++){
if(check(i,x)&&check(s-i,x)){
cout<<"2\n"<<i<<" "<<s-i<<"\n";
return;
}
}
for(int i=1;i<=x;i++){
if(!check(i,x))continue;
for(int j=1;j<=x;j++){
if(check(j,x)&&check(s-i-j,x)){
cout<<"3\n"<<i<<" "<<j<<" "<<s-i-j<<"\n";
return;
}
}
}
for(int i=1;i<=x;i++){
if(!check(i,x))continue;
for(int j=1;j<=x;j++){
if(!check(j,x))continue;
for(int k=1;k<=x;k++){
if(check(k,x)&&check(s-i-j-k,x)){
cout<<"4\n"<<i<<" "<<j<<" "<<k<<" "<<s-i-j-k<<"\n";
return;
}
}
}
}
assert(0);
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1;
// cin>>t;
while(t--)solve();
}
/*
x
y
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1000000000 223092870
output:
2 29 999999971
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 1000000000
output:
2 1 1
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
649557664 933437700
output:
2 11 649557653
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
33396678 777360870
output:
2 1 33396677
result:
ok Correct
Test #7:
score: -100
Time Limit Exceeded
input:
48205845 903124530