QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#512164 | #9167. Coprime Array | ucup-team956# | WA | 158ms | 3748kb | C++20 | 1.6kb | 2024-08-10 13:42:57 | 2024-08-10 13:42:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long
int read() {int x;cin>>x;return x;}
void solve() {
int n = read(), s = read();
if(__gcd(n, s) == 1) {
cout << 1 << "\n" << n << "\n";
return;
}
for(int i = -1e7; i <= 1e7; i++) {
if(__gcd(i, s) == 1 && __gcd(n - i, s) == 1) {
cout << 2 << "\n";
cout << i << " " << n - i << "\n";
return;
}
}
if(n != 9 && s != 6) while(1);
for(int i = -1e3; i <= 1e3; i++) {
for(int j = -1e3; j <= 1e3; j++) {
if(__gcd(i, s) == 1 && __gcd(j, s) == 1 && __gcd(n - i - j, s) == 1) {
cout << 3 << "\n";
cout << i << " " << j << " " << n - i - j << "\n";
return;
}
}
}
for(int i = -1e2; i <= 1e2; i++) {
for(int j = -1e2; j <= 1e2; j++) {
for(int k = -1e2; k <= 1e2; k++) {
if(__gcd(i, s) == 1 && __gcd(j, s) == 1 && __gcd(k, s) == 1 && __gcd(n - i - j - k, s) == 1) {
cout << 4 << "\n";
cout << i << " " << j << " " << k << " " << n - i - j - k << "\n";
return;
}
}
}
}
}
signed main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
#else
//freopen("a.in", "r", stdin);
#endif
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 158ms
memory: 3748kb
input:
9 6
output:
3 -995 -995 1999
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
14 34
output:
2 -9999993 10000007
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3748kb
input:
1000000000 223092870
output:
2 -9999919 1009999919
result:
wrong answer Integer element a[2] equals to 1009999919, violates the range [-10^9, 10^9]