QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513244#9167. Coprime Arrayucup-team004#AC ✓0ms3756kbC++201.2kb2024-08-10 17:17:552024-08-10 17:17:57

Judging History

你现在查看的是测评时间为 2024-08-10 17:17:57 的历史记录

  • [2024-10-14 07:52:07]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:0ms
  • 内存:3788kb
  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 17:17:57]
  • 评测
  • 测评结果:100
  • 用时:0ms
  • 内存:3756kb
  • [2024-08-10 17:17:55]
  • 提交

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

std::mt19937 rng {std::chrono::steady_clock::now().time_since_epoch().count()};

constexpr i64 inf = 1E9;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int s, x;
    std::cin >> s >> x;
    
    if (std::gcd(s, x) == 1) {
        std::cout << 1 << "\n";
        std::cout << s << "\n";
        return 0;
    }
    
    if (x % 2 == 0 && s % 2 != 0) {
        std::cout << 3 << "\n";
        if (s > 0) {
            std::cout << 1 << " ";
            s--;
        } else {
            std::cout << 1 - x << " ";
            s -= 1 - x;
        }
    } else {
        std::cout << 2 << "\n";
    }
    
    while (true) {
        i64 a = inf - rng() % x;
        i64 b = s - a;
        if (b < -inf) {
            i64 t = (-inf - b);
            t = (t + x - 1) / x * x;
            b += t;
            a -= t;
        }
        if (std::abs(a) > inf || std::abs(b) > inf || std::gcd(a, x) != 1 || std::gcd(b, x) != 1) {
            continue;
        }
        std::cout << a << " " << b << "\n";
        return 0;
    }
    
    return 0;
}

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

详细

Test #1:

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

input:

9 6

output:

3
1 999999997 -999999989

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
999999983 -999999969

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
973374497 26625503

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
223647069 -223647067

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
854985347 -205427683

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
491502371 -458105693

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
1 189992947 -141787103

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
762075211 -511038133

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
907815289 -877792369

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
705061337 -641422039

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
1 642526663 -565947647

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
1 989157739 -948734071

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
950749927 -501472618

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
1 488657363 -406991395

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
985042579 -514463899

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
261398773 -202948433

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
1 765183769 -639287657

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
636894907 -254989559

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
1 957791983 -922004099

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed