QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513758#9167. Coprime Arrayucup-team3734#AC ✓0ms3712kbC++23797b2024-08-10 19:31:362024-08-10 19:31:36

Judging History

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

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

answer

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

#define all(x) (x).begin(), (x).end()

ll gcd(ll x, ll y) {
  while (x) {
    y %= x;
    swap(x, y);
  }
  return x + y;
}

int main() {
  ios_base::sync_with_stdio(false);

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

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

  if (x % 2 == 0 && s % 2 == 1) { // 3
    cout << "3\n";
    for (ll k = 0; ; ++k)
      if (gcd(k, x) == 1 && gcd(s - 1 - k, x) == 1) {
        cout << s - k - 1 << " " << (k) << " 1\n";
        return 0;
      }
  } else {
    for (ll k = 0; ; ++k) {
      if (gcd(k, x) == 1 && gcd(s - k, x) == 1) {
        cout << "2\n";
        cout << s - k << " " << (k) << "\n";
        return 0;
      }
    }
  }

  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
7 1 1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
13 1

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
999999971 29

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
1 1

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
649557653 11

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
33396677 1

result:

ok Correct

Test #7:

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

input:

48205845 903124530

output:

3
48205813 31 1

result:

ok Correct

Test #8:

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

input:

251037078 505905400

output:

2
251037077 1

result:

ok Correct

Test #9:

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

input:

30022920 172746860

output:

2
30022919 1

result:

ok Correct

Test #10:

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

input:

63639298 808058790

output:

2
63639269 29

result:

ok Correct

Test #11:

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

input:

76579017 362768406

output:

3
76579015 1 1

result:

ok Correct

Test #12:

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

input:

40423669 121437778

output:

3
40423667 1 1

result:

ok Correct

Test #13:

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

input:

449277309 720915195

output:

2
449277308 1

result:

ok Correct

Test #14:

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

input:

81665969 919836918

output:

3
81665963 5 1

result:

ok Correct

Test #15:

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

input:

470578680 280387800

output:

2
470578679 1

result:

ok Correct

Test #16:

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

input:

58450340 803305503

output:

2
58450339 1

result:

ok Correct

Test #17:

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

input:

125896113 323676210

output:

3
125896081 31 1

result:

ok Correct

Test #18:

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

input:

381905348 434752500

output:

2
381905347 1

result:

ok Correct

Test #19:

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

input:

78916498 653897673

output:

1
78916498

result:

ok Correct

Test #20:

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

input:

35787885 270845190

output:

3
35787883 1 1

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed