QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#511773 | #9167. Coprime Array | ucup-team3699# | WA | 0ms | 3696kb | C++20 | 1.3kb | 2024-08-10 10:52:38 | 2024-08-10 10:52:38 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define N 200005
#define pii pair<int, int>
#define F first
#define S second
int gcd(int a, int b){
return (b == 0 ? a : gcd(b, a % b));
}
int s, x;
void solve(){
cin >> s >> x;
if(gcd(s, x) == 1){
cout << "1\n";
cout << s << "\n";
return;
}
for (int i = 1; i <= 1000000; i++){
// if(i >= 3)
// cout << s << " " << x << "\n";
if(gcd(s - i, x) == 1){
cout << i + 1 << "\n";
for (int t = 1; t <= i; t++)
cout << "1 ";
cout << s - i << "\n";
return;
}
if(gcd(s + i, x) == 1){
cout << i + 1 << "\n";
for (int t = 1; t <= i; t++)
cout << "-1 ";
cout << s + i << "\n";
return;
}
}
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
// signed main(){
// ios_base::sync_with_stdio(0), cin.tie(0);
// for (s = 2; s <= 100; s++){
// for (x = 2; x <= 100; x++){
// // cout << s << " " << x << "\n";
// solve();
// }
// }
// return 0;
// }
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
9 6
output:
3 1 1 7
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3696kb
input:
1000000000 223092870
output:
4 1 1 1 999999997
result:
wrong answer Jury's answer is better than participant's