QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549531#9167. Coprime Arrayucup-team3519#Compile Error//C++231016b2024-09-06 17:06:432024-09-06 17:06:43

Judging History

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

  • [2024-09-06 17:06:43]
  • 评测
  • [2024-09-06 17:06:43]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = int64_t;

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

int main() {
    i64 s, x;
    std::cin >> s >> x;

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

    std::uniform_int_distribution<int> dist(0, x - 1);

    bool flag = false;
    auto get = [&](i64 s) {
        int T = 1e7;
        while (T--) {
            i64 a = dist(rng), b = s - a;
            if (llabs(std::gcd(a, x)) == 1 && llabs(std::gcd(b, x)) == 1) {
                flag = true;
                return std::make_pair(a, b);
            }
        }
        return std::make_pair(0LL, 0LL);
    };

    auto [a, b] = get(s);
    if (flag) {
        std::cout << "2\n";
        std::cout << a << ' ' << b << '\n';
        return 0;
    }

    auto [p, q] = get(s + 1);
    assert(flag);
    std::cout << "3\n";
    std::cout << "-1 " << p << ' ' << q << '\n';
}

Details

answer.code: In lambda function:
answer.code:29:30: error: inconsistent types ‘std::pair<long int, long int>’ and ‘std::pair<long long int, long long int>’ deduced for lambda return type
   29 |         return std::make_pair(0LL, 0LL);
      |                ~~~~~~~~~~~~~~^~~~~~~~~~