QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#512042 | #9167. Coprime Array | ucup-team987# | AC ✓ | 0ms | 3756kb | C++20 | 4.6kb | 2024-08-10 13:21:41 | 2024-08-10 13:21:41 |
Judging History
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(std::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
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
9 6
output:
3 241560455 604692305 -846252751
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
14 34
output:
2 991300015 -991300001
result:
ok Correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1000000000 223092870
output:
2 12349067 987650933
result:
ok Correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
2 1000000000
output:
2 983666449 -983666447
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
649557664 933437700
output:
2 251912837 397644827
result:
ok Correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
33396678 777360870
output:
2 200059649 -166662971
result:
ok Correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
48205845 903124530
output:
3 64987651 707675623 -724457429
result:
ok Correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
251037078 505905400
output:
2 371699099 -120662021
result:
ok Correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
30022920 172746860
output:
2 532427393 -502404473
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
63639298 808058790
output:
2 263529041 -199889743
result:
ok Correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
76579017 362768406
output:
3 446521525 406486903 -776429411
result:
ok Correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
40423669 121437778
output:
3 467697415 299791057 -727064803
result:
ok Correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
449277309 720915195
output:
2 609317237 -160039928
result:
ok Correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
81665969 919836918
output:
3 86034853 210193127 -214562011
result:
ok Correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
470578680 280387800
output:
2 289765849 180812831
result:
ok Correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
58450340 803305503
output:
2 334303903 -275853563
result:
ok Correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
125896113 323676210
output:
3 257072957 713182127 -844358971
result:
ok Correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
381905348 434752500
output:
2 383265781 -1360433
result:
ok Correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
78916498 653897673
output:
1 78916498
result:
ok Correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
35787885 270845190
output:
3 34442267 686400437 -685054819
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed