QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#512036#9167. Coprime Arrayucup-team987#Compile Error//C++204.6kb2024-08-10 13:21:072024-08-10 13:21:07

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 13:21:07]
  • 评测
  • [2024-08-10 13:21:07]
  • 提交

answer

#if __INCLUDE_LEVEL__ == 0

#include __BASE_FILE__

void Solve() {
  int s, x;
  IN(s, x);
  if (gcd(s, x) == 1) {
    OUT(1);
    OUT(s);
    return;
  }
  constexpr int L = 1e9;
  if (s % 2 && x % 2 == 0) {
    while (true) {
      int a = RandInt(1, L);
      int b = RandInt(1, L);
      int c = s - a - b;
      if (abs(c) <= L && gcd(a, x) == 1 && gcd(b, x) == 1 && gcd(c, x) == 1) {
        OUT(3);
        OUT(a, b, c);
        return;
      }
    }
  } else {
    while (true) {
      int a = RandInt(1, L);
      if (gcd(a, x) == 1 && gcd(s - a, x) == 1) {
        OUT(2);
        OUT(a, s - a);
        return;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  Solve();
}

#elif __INCLUDE_LEVEL__ == 1

#include <bits/stdc++.h>

template <class T> concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;

namespace std {

istream& operator>>(istream& is, Range auto&& r) {
  for (auto&& e : r) {
    is >> e;
  }
  return is;
}

istream& operator>>(istream& is, Tuple auto&& t) {
  return apply([&](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}

ostream& operator<<(ostream& os, Range auto&& r) {
  for (string_view sep = ""; auto&& e : r) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

ostream& operator<<(ostream& os, Tuple auto&& t) {
  return apply([&](auto&... xs) -> ostream& {
    [[maybe_unused]] string_view sep = "";
    ((os << exchange(sep, " ") << xs), ...);
    return os; }, t);
}

}  // namespace std

#define DEF_INC_OR_DEC(op) \
  auto& operator op(Tuple auto&&); \
  auto& operator op(Range auto&& r) { \
    for (auto&& e : r) { \
      op e; \
    } \
    return r; \
  } \
  auto& operator op(Tuple auto&& t) { \
    std::apply([](auto&... xs) { (op xs, ...); }, t); \
    return t; \
  }

DEF_INC_OR_DEC(++)
DEF_INC_OR_DEC(--)

#undef DEF_INC_OR_DEC

namespace xorshift {

constexpr size_t N = 8;
inline auto x = [] {
  std::array<uint64_t, N> ret;
  std::mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
  std::ranges::generate(ret, mt);
  return ret;
}();
inline size_t r = N - 1;

inline uint64_t Next() {
  if (++r == N) {
    r = 0;
    for (size_t i = 0; i < N; ++i) {
      x[i] ^= x[i] << 7;
      x[i] ^= x[i] >> 9;
    }
  }
  return x[r];
}

}  // namespace xorshift

inline int64_t RandInt(int64_t a, int64_t b) {
  return a + static_cast<int64_t>(__uint128_t(b - a + 1) * xorshift::Next() >> 64);
}

inline std::pair<int64_t, int64_t> RandInt2(int64_t a, int64_t b) {
  int64_t x = RandInt(a, b - 1);
  int64_t y = RandInt(a, b);
  if (y == x) {
    y = b;
  } else if (y < x) {
    std::swap(x, y);
  }
  return {x, y};
}

template <std::ranges::random_access_range R>
void Shuffle(R&& r) {
  int64_t n = ssize(r);
  if (n < 2) {
    return;
  }
  for (int64_t i = 1; i < n; ++i) {
    if (int64_t j = RandInt(0, i); j < i) {
      swap(r[i], r[j]);
    }
  }
}

inline double Uniform() {
  return static_cast<double>(xorshift::Next()) / static_cast<double>(UINT64_MAX);
}
inline double Uniform(double a, double b) { return a + (b - a) * Uniform(); }

#define IN(...) cin >> forward_as_tuple(__VA_ARGS__)
#define OUT(...) cout << forward_as_tuple(__VA_ARGS__) << '\n'

using namespace std;

using views::filter, views::transform, views::take, views::drop;

constexpr auto Rev = views::reverse;

constexpr auto Rep(int l, int r) { return views::iota(min(l, r), r); }
constexpr auto Rep(int n) { return Rep(0, n); }
constexpr auto Rep1(int l, int r) { return Rep(l, r + 1); }
constexpr auto Rep1(int n) { return Rep(1, n + 1); }

constexpr auto DivFloor(auto x, auto y) { return x / y - ((x ^ y) < 0 && x % y != 0); }
constexpr auto DivCeil(auto x, auto y) { return x / y + (0 <= (x ^ y) && x % y != 0); }
constexpr auto Floor(auto x, auto y) { return DivFloor(x, y) * y; }
constexpr auto Floor(auto x, auto y, auto z) { return Floor(x - z, y) + z; }
constexpr auto Ceil(auto x, auto y) { return DivCeil(x, y) * y; }
constexpr auto Ceil(auto x, auto y, auto z) { return Ceil(x - z, y) + z; }
constexpr auto Mod(auto x, auto y) { return x - Floor(x, y); }

template <class T, class U = T> bool SetMin(T& x, U&& y) { return y < x && (x = forward<U>(y), true); }
template <class T, class U = T> bool SetMax(T& x, U&& y) { return x < y && (x = forward<U>(y), true); }

constexpr int INF = INT_MAX / 2;
constexpr int64_t INF64 = INT64_MAX / 2;

#endif  // __INCLUDE_LEVEL__ == 1

详细

In file included from answer.code:3:
answer.code: In lambda function:
answer.code:103:22: error: ‘chrono’ has not been declared
  103 |   std::mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
      |                      ^~~~~~