QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722898 | #9167. Coprime Array | xieliren | WA | 0ms | 3808kb | C++14 | 840b | 2024-11-07 20:32:26 | 2024-11-07 20:32:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int read(){
int s = 0, f = 1;char ch = getchar();
while(!isdigit(ch)){if(ch == '-')f = -1;ch = getchar();}
while(isdigit(ch)){s = s * 10 + ch - '0';ch = getchar();}
return s * f;
}
void write(int x){
if(x < 0){putchar('-'); x = -x;}
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
int main(){
int n = read(), m = read();
if(__gcd(n, m) == 1){
printf("1\n%d", n);
return 0;
}
if(m % 2 == 0 && n % 2 == 1){
for(int i = -1;;i --){
int h = n - i * 2;
if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
printf("3\n%d %d %d\n", i, i, h);
return 0;
}
}
}
else{
for(int i = -1;;i --){
int h = n - i;
if(__gcd(h, m) == 1 && __gcd(-i, m) == 1){
printf("2\n%d %d\n", i, h);
return 0;
}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
9 6
output:
3 -1 -1 11
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
14 34
output:
2 -1 15
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
1000000000 223092870
output:
2 -31 1000000031
result:
wrong answer Integer element a[2] equals to 1000000031, violates the range [-10^9, 10^9]