QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513730#9167. Coprime Arrayucup-team3734#WA 0ms3708kbC++23800b2024-08-10 19:20:562024-08-10 19:20:57

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 19:20:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-08-10 19:20:56]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9 6

output:

3
11 -1 -1

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
15 -1

result:

ok Correct

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

1000000000 223092870

output:

2
1000000031 -31

result:

wrong answer Integer element a[1] equals to 1000000031, violates the range [-10^9, 10^9]