QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#516557 | #9167. Coprime Array | KavenSky | WA | 2ms | 3652kb | C++23 | 848b | 2024-08-12 18:40:41 | 2024-08-12 18:40:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
using ll = long long;
const ll N = 2e5 + 5;
void solve(){
ll s,x;
cin >> s >> x;
if(__gcd(s,x)==1){
cout << 1 << "\n";
cout << s << "\n";
return;
}
for(ll i=x;i<=x+100000;i++){
if(__gcd(x,i)==1&&__gcd(s-i,x)==1){
cout << 2 << "\n";
cout << i << " " << s-i << "\n";
return;
}
}
for(ll i=x;i<=x+100000;i++){
if(__gcd(x,i)==1&&__gcd(s-1-i,x)==1){
cout << 3 << "\n";
cout << i << " " << s-i-1 << " " << 1 << "\n";
return;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
ll T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3552kb
input:
9 6
output:
3 7 1 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
14 34
output:
2 41 -27
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1000000000 223092870
output:
2 223092899 776907101
result:
ok Correct
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
2 1000000000
output:
2 1000000001 -999999999
result:
wrong answer Integer element a[1] equals to 1000000001, violates the range [-10^9, 10^9]