QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#665546 | #9167. Coprime Array | CruiseY_ | WA | 0ms | 3804kb | C++14 | 1.2kb | 2024-10-22 13:58:28 | 2024-10-22 13:58:28 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define pb push_back
using namespace std;
ll read() {
ll x = 0, f = 1; char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
return x * f;
}
const int mod = 998244353;
#define mid ((l + r) >> 1)
ll ksm(ll x, ll y) {
ll base = 1;
for(; y; y >>= 1) {
if(y & 1) base = base * x % mod;
x = x * x % mod;
}
return base;
}
ll q[100], ct;
ll n, m, a, b, sum;
int main() {
n = read(); m = read(); sum = 1;
if(__gcd(n, m) == 1) return printf("1\n%lld", n), 0;
if((n & 1) && !(m & 1)) printf("3\n1 "), n--;
else printf("2\n");
a = n + 1; b = 1;
for(int i = 2; i * i <= m; i++) {
if(!(m % i)) q[++ct] = i;
while(!(m % i)) m /= i;
}
if(m != 1) q[++ct] = m;
sort(q + 1, q + 1 + ct);
for(int i = 1; i <= ct; i++) {
while(!(a % q[i]) || !(b % q[i])) a += sum, b += sum;
sum = sum * q[i];
}
printf("%lld %lld", a, -b);
return 0;
}
/*
10000
9
JAAAJAJAA
AJAJJAJAA
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
9 6
output:
3 1 13 -5
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
14 34
output:
2 15 -1
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3792kb
input:
1000000000 223092870
output:
2 1000000031 -31
result:
wrong answer Integer element a[1] equals to 1000000031, violates the range [-10^9, 10^9]