QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665556#9167. Coprime ArrayCruiseY_AC ✓0ms3928kbC++141.2kb2024-10-22 14:01:592024-10-22 14:02:05

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 14:02:05]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3928kb
  • [2024-10-22 14:01:59]
  • 提交

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
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3772kb

input:

9 6

output:

3
1 7 1

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

14 34

output:

2
15 -1

result:

ok Correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

1000000000 223092870

output:

2
999999971 29

result:

ok Correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

2 1000000000

output:

2
3 -1

result:

ok Correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

649557664 933437700

output:

2
649557653 11

result:

ok Correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

33396678 777360870

output:

2
33396679 -1

result:

ok Correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

48205845 903124530

output:

3
1 48205813 31

result:

ok Correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

251037078 505905400

output:

2
251037079 -1

result:

ok Correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

30022920 172746860

output:

2
30022921 -1

result:

ok Correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

63639298 808058790

output:

2
63639299 -1

result:

ok Correct

Test #11:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

76579017 362768406

output:

3
1 76579015 1

result:

ok Correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

40423669 121437778

output:

3
1 40423655 13

result:

ok Correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

449277309 720915195

output:

2
449277307 2

result:

ok Correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

81665969 919836918

output:

3
1 81665963 5

result:

ok Correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

470578680 280387800

output:

2
470578681 -1

result:

ok Correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

58450340 803305503

output:

2
58450339 1

result:

ok Correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

125896113 323676210

output:

3
1 125896081 31

result:

ok Correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

381905348 434752500

output:

2
381905347 1

result:

ok Correct

Test #19:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

35787885 270845190

output:

3
1 35787883 1

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed