QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598085#9167. Coprime ArrayfosovAC ✓132ms3724kbC++141.2kb2024-09-28 20:27:492024-09-28 20:27:51

Judging History

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

  • [2024-09-28 20:27:51]
  • 评测
  • 测评结果:AC
  • 用时:132ms
  • 内存:3724kb
  • [2024-09-28 20:27:49]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

using ll = long long;

#define INF 0x3f3f3f3f
#define LNF (ll) 0x3f3f3f3f3f3f3f3f 

#define MOD 998244353
#define N 220

ll grand() {
    return 1e9 - rand() % (int) 2e9;
}

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    

    ll s, x; cin >> s >> x;

    if (__gcd(s, x) == 1) {
        cout << 1 << '\n';
        cout << s << '\n';
        return 0;
    }

    for (int i = 0; i < 1e6; ++ i) {
        ll a = grand();
        if (__gcd(a, x) != 1) continue;
        ll b = s - a;
        if (__gcd(b, x) != 1 || abs(b) > 1e9) continue;
        cout << 2 << '\n';
        cout << a << ' ' << b << '\n';
        return 0;
    }

    for (int i = 0; i < 1e6; ++ i) {
        ll a = grand(), b = grand();
        if (__gcd(a, x) != 1 || __gcd(b, x) != 1) continue;
        ll c = s - a - b;
        if (__gcd(c, x) != 1 || abs(c) > 1e9) continue;
        cout << 3 << '\n';
        cout << a << ' ' << b << ' ' << c << '\n';
        return 0;
    }

    cout << -1 << '\n';
    return 0;
}   



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

詳細信息

Test #1:

score: 100
Accepted
time: 25ms
memory: 3716kb

input:

9 6

output:

3
219192289 -863989427 644797147

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
-714636915 714636929

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
682902533 317097467

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
243101463 -243101461

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
-129566413 779124077

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
140515579 -107118901

result:

ok Correct

Test #7:

score: 0
Accepted
time: 128ms
memory: 3664kb

input:

48205845 903124530

output:

3
549999169 -902563553 400770229

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
-189641421 440678499

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
403483351 -373460431

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
-914544919 978184217

result:

ok Correct

Test #11:

score: 0
Accepted
time: 126ms
memory: 3712kb

input:

76579017 362768406

output:

3
919418195 45894545 -888733723

result:

ok Correct

Test #12:

score: 0
Accepted
time: 132ms
memory: 3676kb

input:

40423669 121437778

output:

3
293411313 102496893 -355484537

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
-25202362 474479671

result:

ok Correct

Test #14:

score: 0
Accepted
time: 131ms
memory: 3596kb

input:

81665969 919836918

output:

3
-693063755 398535419 376194305

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
-369133069 839711749

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
403483351 -345033011

result:

ok Correct

Test #17:

score: 0
Accepted
time: 125ms
memory: 3672kb

input:

125896113 323676210

output:

3
418169399 377195693 -669468979

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
140515579 241389769

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

score: 0
Accepted
time: 122ms
memory: 3656kb

input:

35787885 270845190

output:

3
167128727 812242037 -943582879

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed