QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379517 | #8569. Generalized Collatz Conjecture | ucup-team087# | AC ✓ | 4685ms | 690144kb | C++20 | 26.1kb | 2024-04-06 17:44:46 | 2024-04-06 17:44:47 |
Judging History
answer
#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
#define vv(type, name, h, ...) \
vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) \
vector<vector<vector<type>>> name( \
h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name( \
a, vector<vector<vector<type>>>( \
b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
#define FOR_subset(t, s) \
for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define stoi stoll
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
template <typename T>
T floor(T a, T b) {
return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = floor(x, y);
return {q, x - q * y};
}
template <typename T, typename U>
T SUM(const vector<U> &A) {
T sm = 0;
for (auto &&a: A) sm += a;
return sm;
}
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
template <typename T>
T POP(deque<T> &que) {
T a = que.front();
que.pop_front();
return a;
}
template <typename T>
T POP(pq<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(pqg<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
T a = que.back();
que.pop_back();
return a;
}
template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
if (check_ok) assert(check(ok));
while (abs(ok - ng) > 1) {
auto x = (ng + ok) / 2;
(check(x) ? ok : ng) = x;
}
return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
FOR(iter) {
double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
return (a > b ? a = b, 1 : 0);
}
// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
vc<int> A(S.size());
FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
return A;
}
template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
int N = A.size();
vector<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0) B.erase(B.begin());
return B;
}
// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
vector<int> ids(len(A));
iota(all(ids), 0);
sort(all(ids),
[&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
vc<T> B(len(I));
FOR(i, len(I)) B[i] = A[I[i]];
return B;
}
#endif
#line 1 "library/other/io.hpp"
#define FASTIO
#include <unistd.h>
// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[10000][4];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i][j] = n % 10 | '0';
n /= 10;
}
}
}
} constexpr pre;
inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
if (pir < SZ) ibuf[pir++] = '\n';
}
inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
void rd(char &c) {
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
}
void rd(string &x) {
x.clear();
char c;
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
do {
x += c;
if (pil == pir) load();
c = ibuf[pil++];
} while (!isspace(c));
}
template <typename T>
void rd_real(T &x) {
string s;
rd(s);
x = stod(s);
}
template <typename T>
void rd_integer(T &x) {
if (pil + 100 > pir) load();
char c;
do
c = ibuf[pil++];
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (c == '-') { minus = 1, c = ibuf[pil++]; }
}
x = 0;
while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (minus) x = -x;
}
}
void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }
template <class T, class U>
void rd(pair<T, U> &p) {
return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
if constexpr (N < std::tuple_size<T>::value) {
auto &x = std::get<N>(t);
rd(x);
rd_tuple<N + 1>(t);
}
}
template <class... T>
void rd(tuple<T...> &tpl) {
rd_tuple(tpl);
}
template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
for (auto &d: x) rd(d);
}
void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
rd(h), read(t...);
}
void wt(const char c) {
if (por == SZ) flush();
obuf[por++] = c;
}
void wt(const string s) {
for (char c: s) wt(c);
}
void wt(const char *s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) wt(s[i]);
}
template <typename T>
void wt_integer(T x) {
if (por > SZ - 100) flush();
if (x < 0) { obuf[por++] = '-', x = -x; }
int outi;
for (outi = 96; x >= 10000; outi -= 4) {
memcpy(out + outi, pre.num[x % 10000], 4);
x /= 10000;
}
if (x >= 1000) {
memcpy(obuf + por, pre.num[x], 4);
por += 4;
} else if (x >= 100) {
memcpy(obuf + por, pre.num[x] + 1, 3);
por += 3;
} else if (x >= 10) {
int q = (x * 103) >> 10;
obuf[por] = q | '0';
obuf[por + 1] = (x - q * 10) | '0';
por += 2;
} else
obuf[por++] = x | '0';
memcpy(obuf + por, out + outi + 4, 96 - outi);
por += 96 - outi;
}
template <typename T>
void wt_real(T x) {
ostringstream oss;
oss << fixed << setprecision(15) << double(x);
string s = oss.str();
wt(s);
}
void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }
template <class T, class U>
void wt(const pair<T, U> val) {
wt(val.first);
wt(' ');
wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
if constexpr (N < std::tuple_size<T>::value) {
if constexpr (N > 0) { wt(' '); }
const auto x = std::get<N>(t);
wt(x);
wt_tuple<N + 1>(t);
}
}
template <class... T>
void wt(tuple<T...> tpl) {
wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
template <class T>
void wt(const vector<T> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
wt(head);
if (sizeof...(Tail)) wt(' ');
print(forward<Tail>(tail)...);
}
// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;
#define INT(...) \
int __VA_ARGS__; \
read(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
read(__VA_ARGS__)
#define U32(...) \
u32 __VA_ARGS__; \
read(__VA_ARGS__)
#define U64(...) \
u64 __VA_ARGS__; \
read(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
read(__VA_ARGS__)
#define CHAR(...) \
char __VA_ARGS__; \
read(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
read(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
read(name)
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
read(name)
void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"
#line 2 "library/ds/hashmap.hpp"
// u64 -> Val
template <typename Val>
struct HashMap {
HashMap(u32 n = 0) { build(n); }
void build(u32 n) {
u32 k = 8;
while (k < n * 2) k *= 2;
cap = k / 2, mask = k - 1;
key.resize(k), val.resize(k), used.assign(k, 0);
}
void clear() { build(0); }
int size() { return len(used) - cap; }
int index(const u64& k) {
int i = 0;
for (i = hash(k); used[i] && key[i] != k; i = (i + 1) & mask) {}
return i;
}
Val& operator[](const u64& k) {
if (cap == 0) extend();
int i = index(k);
if (!used[i]) { used[i] = 1, key[i] = k, val[i] = Val{}, --cap; }
return val[i];
}
Val get(const u64& k, Val default_value) {
int i = index(k);
return (used[i] ? val[i] : default_value);
}
bool count(const u64& k) {
int i = index(k);
return used[i] && key[i] == k;
}
// f(key, val)
template <typename F>
void enumerate_all(F f) {
FOR(i, len(used)) if (used[i]) f(key[i], val[i]);
}
private:
u32 cap, mask;
vc<u64> key;
vc<Val> val;
vc<bool> used;
u64 hash(u64 x) {
static const u64 FIXED_RANDOM
= std::chrono::steady_clock::now().time_since_epoch().count();
x += FIXED_RANDOM;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return (x ^ (x >> 31)) & mask;
}
void extend() {
vc<pair<u64, Val>> dat;
dat.reserve(len(used) - cap);
FOR(i, len(used)) {
if (used[i]) dat.eb(key[i], val[i]);
}
build(2 * len(dat));
for (auto& [a, b]: dat) (*this)[a] = b;
}
};
#line 2 "library/nt/primetable.hpp"
template <typename T = int>
vc<T> primetable(int LIM) {
++LIM;
const int S = 32768;
static int done = 2;
static vc<T> primes = {2}, sieve(S + 1);
if (done < LIM) {
done = LIM;
primes = {2}, sieve.assign(S + 1, 0);
const int R = LIM / 2;
primes.reserve(int(LIM / log(LIM) * 1.1));
vc<pair<int, int>> cp;
for (int i = 3; i <= S; i += 2) {
if (!sieve[i]) {
cp.eb(i, i * i / 2);
for (int j = i * i; j <= S; j += 2 * i) sieve[j] = 1;
}
}
for (int L = 1; L <= R; L += S) {
array<bool, S> block{};
for (auto& [p, idx]: cp)
for (int i = idx; i < S + L; idx = (i += p)) block[i - L] = 1;
FOR(i, min(S, R - L)) if (!block[i]) primes.eb((L + i) * 2 + 1);
}
}
int k = LB(primes, LIM + 1);
return {primes.begin(), primes.begin() + k};
}
#line 3 "library/nt/lpf_table.hpp"
// [0, LIM], 0, 1 には -1 が入る。
vc<int> lpf_table(ll LIM) {
auto primes = primetable(LIM);
vc<int> res(LIM + 1, -1);
FOR_R(i, len(primes)) {
auto p = primes[i];
FOR3(j, 1, LIM / p + 1) res[p * j] = p;
}
return res;
}
#line 2 "library/nt/factor.hpp"
#line 2 "library/random/base.hpp"
u64 RNG_64() {
static uint64_t x_
= uint64_t(chrono::duration_cast<chrono::nanoseconds>(
chrono::high_resolution_clock::now().time_since_epoch())
.count())
* 10150724397891781847ULL;
x_ ^= x_ << 7;
return x_ ^= x_ >> 9;
}
u64 RNG(u64 lim) { return RNG_64() % lim; }
ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 2 "library/mod/mongomery_modint.hpp"
// odd mod.
// x の代わりに rx を持つ
template <int id, typename U1, typename U2>
struct Mongomery_modint {
using mint = Mongomery_modint;
inline static U1 m, r, n2;
static constexpr int W = numeric_limits<U1>::digits;
static void set_mod(U1 mod) {
assert(mod & 1 && mod <= U1(1) << (W - 2));
m = mod, n2 = -U2(m) % m, r = m;
FOR(5) r *= 2 - m * r;
r = -r;
assert(r * m == U1(-1));
}
static U1 reduce(U2 b) { return (b + U2(U1(b) * r) * m) >> W; }
U1 x;
Mongomery_modint() : x(0) {}
Mongomery_modint(U1 x) : x(reduce(U2(x) * n2)){};
U1 val() const {
U1 y = reduce(x);
return y >= m ? y - m : y;
}
mint &operator+=(mint y) {
x = ((x += y.x) >= m ? x - m : x);
return *this;
}
mint &operator-=(mint y) {
x -= (x >= y.x ? y.x : y.x - m);
return *this;
}
mint &operator*=(mint y) {
x = reduce(U2(x) * y.x);
return *this;
}
mint operator+(mint y) const { return mint(*this) += y; }
mint operator-(mint y) const { return mint(*this) -= y; }
mint operator*(mint y) const { return mint(*this) *= y; }
bool operator==(mint y) const {
return (x >= m ? x - m : x) == (y.x >= m ? y.x - m : y.x);
}
bool operator!=(mint y) const { return not operator==(y); }
mint pow(ll n) const {
assert(n >= 0);
mint y = 1, z = *this;
for (; n; n >>= 1, z *= z)
if (n & 1) y *= z;
return y;
}
};
template <int id>
using Mongomery_modint_32 = Mongomery_modint<id, u32, u64>;
template <int id>
using Mongomery_modint_64 = Mongomery_modint<id, u64, u128>;
#line 3 "library/nt/primetest.hpp"
bool primetest(const u64 x) {
assert(x < u64(1) << 62);
if (x == 2 or x == 3 or x == 5 or x == 7) return true;
if (x % 2 == 0 or x % 3 == 0 or x % 5 == 0 or x % 7 == 0) return false;
if (x < 121) return x > 1;
const u64 d = (x - 1) >> lowbit(x - 1);
using mint = Mongomery_modint_64<202311020>;
mint::set_mod(x);
const mint one(u64(1)), minus_one(x - 1);
auto ok = [&](u64 a) -> bool {
auto y = mint(a).pow(d);
u64 t = d;
while (y != one && y != minus_one && t != x - 1) y *= y, t <<= 1;
if (y != minus_one && t % 2 == 0) return false;
return true;
};
if (x < (u64(1) << 32)) {
for (u64 a: {2, 7, 61})
if (!ok(a)) return false;
} else {
for (u64 a: {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) {
if (!ok(a)) return false;
}
}
return true;
}
#line 5 "library/nt/factor.hpp"
template <typename mint>
ll rho(ll n, ll c) {
assert(n > 1);
const mint cc(c);
auto f = [&](mint x) { return x * x + cc; };
mint x = 1, y = 2, z = 1, q = 1;
ll g = 1;
const ll m = 1LL << (__lg(n) / 5);
for (ll r = 1; g == 1; r <<= 1) {
x = y;
FOR(r) y = f(y);
for (ll k = 0; k < r && g == 1; k += m) {
z = y;
FOR(min(m, r - k)) y = f(y), q *= x - y;
g = gcd(q.val(), n);
}
}
if (g == n) do {
z = f(z);
g = gcd((x - z).val(), n);
} while (g == 1);
return g;
}
ll find_prime_factor(ll n) {
assert(n > 1);
if (primetest(n)) return n;
FOR(100) {
ll m = 0;
if (n < (1 << 30)) {
using mint = Mongomery_modint_32<20231025>;
mint::set_mod(n);
m = rho<mint>(n, RNG(0, n));
} else {
using mint = Mongomery_modint_64<20231025>;
mint::set_mod(n);
m = rho<mint>(n, RNG(0, n));
}
if (primetest(m)) return m;
n = m;
}
assert(0);
return -1;
}
// ソートしてくれる
vc<pair<ll, int>> factor(ll n) {
assert(n >= 1);
vc<pair<ll, int>> pf;
FOR(p, 2, 100) {
if (p * p > n) break;
if (n % p == 0) {
ll e = 0;
do { n /= p, e += 1; } while (n % p == 0);
pf.eb(p, e);
}
}
while (n > 1) {
ll p = find_prime_factor(n);
ll e = 0;
do { n /= p, e += 1; } while (n % p == 0);
pf.eb(p, e);
}
sort(all(pf));
return pf;
}
vc<pair<ll, int>> factor_by_lpf(ll n, vc<int>& lpf) {
vc<pair<ll, int>> res;
while (n > 1) {
int p = lpf[n];
int e = 0;
while (n % p == 0) {
n /= p;
++e;
}
res.eb(p, e);
}
return res;
}
#line 8 "main.cpp"
const int LIM = (1 << 27) + 1;
vc<int> lpf;
char omega[LIM + 1];
const int vmax = LIM + 1;
bool pri[vmax];
vc<int> ps;
#define sf lpf
// vc<int> sf; // smallest factor, sf[1] is undefined(0)
void linear_sieve() {
sf.resize(vmax);
FOR(i, 2, vmax) pri[i] = 1;
FOR(i, 2, vmax) {
if (pri[i]) {
ps.eb(i);
sf[i] = i;
}
for (int j = 0; i * ps[j] < vmax; j++) {
pri[i * ps[j]] = 0;
sf[i * ps[j]] = ps[j];
if (i % ps[j] == 0) break;
}
}
}
void test(vi M) {
ll mx = 1 << 21;
vi dp(mx + 1);
// auto lpf = lpf_table(mx);
FOR(n, 2, mx + 1) {
ll ANS = omega[n];
for (auto& [p, e]: factor_by_lpf(n, lpf)) { chmin(ANS, dp[n / p] + 1); }
HashMap<int> MP;
deque<ll> que;
auto upd = [&](ll x, int d) -> void {
if (MP.count(x)) return;
MP[x] = d;
que.eb(x);
};
upd(n, 0);
while (len(que)) {
auto x = POP(que);
ll d = MP[x];
if (x <= LIM) chmin(ANS, d + omega[x]);
if (x < n) {
chmin(ANS, d + dp[x]);
continue;
}
if (d >= ANS) break;
for (auto& [p, e]: factor(x)) { upd(x / p, d + 1); }
for (auto& m: M) upd(x * m + 1, d + 1);
}
dp[n] = ANS;
if (ANS == 6) {
print(M, n);
flush();
}
}
// ll ma = MAX(dp);
// vi F(ma + 1);
// FOR(n, 1, mx + 1) F[dp[n]]++;
// print("M=", M);
// print("max=", ma);
// print(F);
// print();
// flush();
}
void naive() {
LL(N);
LL(K);
VEC(ll, M, K);
ll ANS = 100;
HashMap<int> MP;
deque<ll> que;
auto upd = [&](ll x, int d) -> void {
if (MP.count(x)) return;
MP[x] = d;
que.eb(x);
};
upd(N, 0);
while (len(que)) {
auto x = POP(que);
ll d = MP[x];
if (x == 1) {
ANS = d;
break;
}
for (auto& [p, e]: factor(x)) { upd(x / p, d + 1); }
for (auto& m: M) upd(x * m + 1, d + 1);
}
print(ANS);
}
int solve() {
LL(N);
ll n = N;
LL(K);
VEC(int, M, K);
vc<int> P;
for (auto& [p, e]: factor_by_lpf(N, lpf)) { P.eb(p); }
auto myprimetest = [&](ll p) -> bool {
return (p <= LIM ? (omega[p] == 1) : primetest(p));
};
// 6手
{
static set<pi> six;
if (six.empty()) {
six.emplace(13, 776576);
six.emplace(17, 1091151);
six.emplace(17, 1343709);
six.emplace(17, 1800063);
six.emplace(29, 1273563);
six.emplace(29, 1718253);
six.emplace(31, 1903993);
six.emplace(35, 1607445);
six.emplace(41, 1151415);
six.emplace(41, 1384047);
six.emplace(41, 1436373);
six.emplace(43, 1233837);
six.emplace(43, 2075949);
six.emplace(47, 178929);
six.emplace(47, 288603);
six.emplace(47, 2045169);
six.emplace(49, 634375);
six.emplace(53, 720171);
six.emplace(53, 905175);
six.emplace(53, 1005939);
six.emplace(53, 1080675);
six.emplace(53, 1180737);
six.emplace(53, 1279395);
six.emplace(53, 1516995);
six.emplace(53, 1597779);
six.emplace(53, 1647675);
six.emplace(53, 1720251);
six.emplace(53, 1858869);
six.emplace(59, 441088);
six.emplace(59, 686313);
six.emplace(59, 950589);
six.emplace(59, 1279744);
six.emplace(59, 1377536);
six.emplace(59, 1629952);
six.emplace(59, 1669376);
six.emplace(59, 1699072);
six.emplace(59, 1972125);
six.emplace(59, 1974256);
six.emplace(59, 2076416);
six.emplace(61, 1180544);
six.emplace(61, 1782784);
}
if (len(M) == 1) {
pi p = {M[0], N};
if (six.count(p)) return 6;
}
}
// 0手
if (N == 1) return 0;
// 1手
if (omega[N] == 1) return 1;
// 2手
{
if (omega[N] == 2) return 2;
for (auto& x: M) {
if (omega[N * x + 1] == 1) return 2;
}
}
// ここで M がとても大きいやつは return 3 してしまいたい
// 3手
{
if (omega[N] == 3) return 3;
// a(n/p)+1=q
for (auto& p: P) {
for (auto& a: M) {
ll q = a * (N / p) + 1;
if (omega[q] == 1) return 3;
}
}
// an+1=pq
for (auto& a: M) {
if (omega[a * N + 1] == 2) return 3;
}
// abn+b+1==p
// やばいと言われている
// |M| が大きいならやらずに 3 を return したい!
for (auto& a: M) {
for (auto& b: M) {
ll x = a * b * N + b + 1;
// |M| がおおきいときやりたくない
if (myprimetest(x)) return 3;
}
}
}
// この辺で M が大きいやつは return 4 してしまいたい
// 4手
if (omega[N] <= 4) return 4;
ll NP = len(P);
FOR(j, NP) FOR(i, j + 1) {
ll p = P[i], q = P[j];
if ((N % (p * q) != 0)) continue;
for (auto& a: M) {
ll r = a * (n / (p * q)) + 1;
if (omega[r] == 1) return 4;
}
}
// a(n/p)+1=qr
for (auto& p: P) {
for (auto& a: M) {
ll x = a * (n / p) + 1;
if (omega[x] == 2) return 4;
}
}
// ab(n/p)+b+1=q
// やばい
for (auto& p: P) {
for (auto& a: M) {
for (auto& b: M) {
ll x = a * b * (n / p) + b + 1;
if (myprimetest(x)) return 4;
}
}
}
// an+1=pqr
for (auto& a: M) {
if (omega[a * N + 1] == 3) return 4;
}
// b((an+1)/p)+1=q
for (auto& a: M) {
for (auto& [p, e]: factor_by_lpf(a * n + 1, lpf)) {
for (auto& b: M) {
ll x = b * (a * n + 1) / p + 1;
if (myprimetest(x)) return 4;
}
}
}
// abn+b+1=pq
for (auto& a: M) {
for (auto& b: M) {
ll x = a * b * n + b + 1;
if (x <= LIM) {
if (omega[x] == 2) return 4;
} else {
auto pfs = factor(x);
ll o = 0;
for (auto& [p, e]: pfs) o += e;
if (o <= 2) return 4;
}
}
}
// +++-
for (auto& a: M) {
for (auto& b: M) {
for (auto& c: M) {
ll x = a * b * c * n + b * c + c + 1;
if (myprimetest(x)) return 4;
}
}
}
// 5以上
return 5;
}
signed main() {
lpf = lpf_table((1 << 27) + 1);
FOR(n, 2, LIM + 1) {
int p = lpf[n];
omega[n] = omega[n / p] + 1;
}
INT(T);
FOR(T) print(solve());
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3703ms
memory: 689012kb
input:
2 84 2 3 6 18588 3 18 25 44
output:
3 4
result:
ok 2 tokens
Test #2:
score: 0
Accepted
time: 4685ms
memory: 689756kb
input:
262144 1576395 1 37 1190799 2 11 17 520479 1 29 1676079 1 49 1202944 2 41 47 1906335 2 25 47 1862541 1 47 1879366 1 19 1225773 1 17 1819737 1 59 205155 1 53 1498304 1 61 818565 1 43 1482543 2 41 61 228771 1 59 758241 2 11 23 815056 1 59 576153 1 53 458541 1 35 950211 2 5 29 1495625 1 53 1962415 1 59...
output:
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
result:
ok 262144 tokens
Test #3:
score: 0
Accepted
time: 4429ms
memory: 689328kb
input:
262144 1492393 1 27 1517074 1 23 819009 1 35 1064505 1 3 991575 1 49 489969 1 31 1653561 1 59 1673625 1 19 443385 1 53 1789641 1 39 481915 1 5 1751715 2 5 53 602651 1 61 1721685 1 61 1032795 1 41 605493 1 47 1672192 3 16 29 58 325809 1 39 896704 1 17 1688067 1 61 567520 1 31 2082915 1 23 1879551 1 2...
output:
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
result:
ok 262144 tokens
Test #4:
score: 0
Accepted
time: 3923ms
memory: 689336kb
input:
262144 1078425 3 35 54 59 1954665 4 43 47 51 59 857175 3 27 49 59 1725032 3 28 31 55 1252611 3 17 53 64 1786023 4 17 27 48 51 1895925 3 53 59 64 1801202 3 25 43 64 1299429 4 17 31 47 63 1467315 3 30 41 47 1094205 3 14 19 23 1430433 3 17 50 53 1142019 3 21 23 53 376155 3 23 38 53 858141 4 11 47 56 62...
output:
3 3 4 3 4 3 3 3 3 3 3 3 3 2 3 3 4 3 3 3 3 2 4 3 3 3 3 3 3 4 3 4 3 3 4 3 3 4 3 3 3 3 3 4 4 4 3 4 2 3 4 3 3 4 3 2 4 3 3 3 2 3 3 3 3 4 3 3 4 2 3 4 2 4 2 2 2 3 3 2 3 4 3 3 4 3 4 3 3 4 3 4 3 3 3 3 4 2 3 4 4 3 2 3 3 3 3 3 3 2 3 2 3 4 3 3 4 3 3 4 3 3 3 4 3 3 3 2 4 4 3 3 2 3 4 2 3 2 2 3 2 4 4 3 2 3 3 4 4 3 ...
result:
ok 262144 tokens
Test #5:
score: 0
Accepted
time: 3877ms
memory: 689092kb
input:
262144 580864 3 52 61 63 1709461 3 28 42 55 1572864 2 38 39 1632915 2 49 53 1022625 2 29 59 1883136 8 5 11 19 21 27 35 45 55 596835 3 30 49 62 196587 3 21 42 55 1272750 6 21 27 37 41 45 51 1081593 2 32 55 1757775 2 49 63 1811556 7 22 25 28 29 59 60 62 1698435 2 33 49 140625 2 19 50 1732992 2 8 48 12...
output:
2 2 3 4 4 2 3 3 2 3 4 3 3 4 3 2 4 4 4 3 3 3 2 3 3 3 3 2 2 3 3 2 3 3 3 3 3 2 3 3 4 3 2 3 3 2 3 3 3 4 4 2 2 3 3 3 3 3 3 2 3 3 2 4 4 3 3 4 3 3 4 4 2 3 2 2 4 3 3 3 3 3 3 3 2 2 4 3 3 3 3 3 3 4 4 3 4 2 2 3 4 3 3 3 3 3 3 4 2 3 3 2 3 3 2 3 3 3 3 3 3 4 3 2 3 2 3 2 2 3 4 2 3 3 3 3 3 4 4 3 4 3 4 3 3 3 2 4 2 3 ...
result:
ok 262144 tokens
Test #6:
score: 0
Accepted
time: 3787ms
memory: 689460kb
input:
262144 2044416 3 5 17 33 1531872 5 21 27 31 51 55 2035886 2 3 37 1032750 6 29 37 41 49 53 57 910224 4 29 45 51 55 730944 3 23 35 45 993408 2 28 43 1606144 2 23 28 1636633 2 13 37 1875968 1 37 1633800 2 33 47 1519616 2 13 59 1609728 3 23 27 41 1792000 8 3 7 25 27 29 49 53 63 844050 1 14 1269504 1 13 ...
output:
2 3 3 2 3 3 3 2 2 4 2 3 3 2 3 4 3 2 3 4 3 3 2 4 2 2 3 3 3 3 2 3 3 2 3 3 2 2 2 2 3 3 3 2 3 2 4 2 4 2 4 2 3 3 3 3 4 2 2 3 2 2 2 2 2 2 4 3 2 3 2 2 3 2 3 3 3 3 2 2 3 4 3 2 3 3 4 2 2 3 3 3 2 2 3 4 3 2 2 2 3 2 3 3 3 2 2 3 4 3 3 2 2 3 2 3 4 3 3 3 3 2 3 2 2 2 2 4 2 3 2 2 2 3 2 3 4 3 3 2 3 2 3 3 3 3 3 2 2 3 ...
result:
ok 262144 tokens
Test #7:
score: 0
Accepted
time: 3804ms
memory: 689492kb
input:
262144 1081344 8 35 41 43 47 51 57 59 61 2062976 8 33 37 49 51 53 55 57 59 1798304 8 35 39 41 43 51 57 59 61 1341856 8 35 37 41 45 47 51 55 61 817600 8 15 17 21 29 37 41 45 59 1576788 8 33 39 51 53 55 57 59 63 1843875 8 33 39 43 49 53 55 61 63 1647360 8 33 37 41 47 49 57 59 63 546848 8 33 39 45 51 5...
output:
2 2 2 2 2 3 3 2 2 3 2 2 3 3 3 2 2 3 2 2 3 2 2 2 2 2 2 2 2 3 2 2 2 2 3 2 2 2 2 3 2 2 2 2 2 2 2 3 2 2 2 2 2 3 2 2 2 2 2 2 3 2 3 2 3 2 3 2 2 2 3 2 3 3 2 2 3 2 2 2 2 2 2 2 2 3 3 2 2 2 2 2 3 3 3 3 3 3 2 2 2 2 2 3 3 2 3 2 2 2 3 2 2 3 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 3 2 2 2 3 2 2 2 ...
result:
ok 262144 tokens
Test #8:
score: 0
Accepted
time: 3714ms
memory: 690144kb
input:
262144 74 2 18 57 682 3 20 31 47 1141614 2 11 62 178 2 7 35 940 2 31 58 1280 2 39 53 2097151 2 28 41 225 2 34 42 574 1 29 225 2 3 26 584 3 20 24 41 948 3 28 29 44 386 3 24 45 62 763 2 14 35 2097097 1 35 954 4 9 15 33 53 42 1 5 225 2 4 33 304 5 7 16 34 55 56 2097138 2 13 37 112 2 6 38 89 2 17 36 938 ...
output:
2 2 3 2 2 2 3 3 3 2 2 3 2 2 1 3 2 3 2 3 2 1 2 2 4 2 3 2 2 3 3 1 3 3 3 2 3 1 3 2 1 1 3 2 3 3 3 1 2 3 2 1 3 1 3 2 3 3 2 3 1 2 2 3 1 2 3 1 4 1 3 3 2 2 2 2 1 3 3 2 2 2 2 1 2 2 3 2 2 2 1 3 2 3 2 2 3 4 2 2 2 1 3 2 1 3 2 1 1 2 3 3 1 1 1 2 2 3 2 1 3 2 2 2 3 3 3 2 3 1 2 2 3 2 1 2 3 3 2 3 2 1 3 3 1 2 3 4 3 2 ...
result:
ok 262144 tokens
Test #9:
score: 0
Accepted
time: 3739ms
memory: 689544kb
input:
262144 873 2 36 51 2097090 6 4 23 26 43 46 54 713 1 51 94 2 40 43 1110 3 6 26 42 188 2 26 36 2097077 3 20 23 35 52 3 12 46 61 56 2 20 63 418 4 33 49 59 61 245 2 38 57 114 2 15 39 171 2 16 26 388 7 41 45 48 55 59 60 62 844 3 26 28 30 644 3 23 25 28 493 2 36 50 62 2 12 21 418 3 2 36 60 697 2 29 57 276...
output:
3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 1 2 2 2 2 2 2 2 3 3 3 2 2 2 2 3 3 2 3 2 3 2 2 2 1 2 2 1 2 3 2 1 2 3 2 1 3 2 3 1 2 3 2 2 2 3 2 2 2 2 2 3 3 2 2 2 3 1 2 2 2 3 2 2 2 4 1 1 3 1 2 2 2 1 2 2 2 2 2 2 2 1 2 3 2 2 2 2 2 2 3 2 3 2 2 2 2 3 2 2 2 2 3 2 3 2 2 1 2 2 2 3 2 2 1 1 2 2 2 3 2 2 2 3 2 1 1 4 2 ...
result:
ok 262144 tokens
Test #10:
score: 0
Accepted
time: 3739ms
memory: 689180kb
input:
262144 40 2 17 55 692 3 17 52 61 27 2 51 61 119 2 32 50 382 3 50 52 56 530 3 14 46 55 476032 2 21 49 726 2 2 5 1071 2 34 44 159 5 5 31 47 57 61 200 2 47 59 554 2 1 41 209 2 26 40 235 2 29 64 40 2 14 50 1517568 3 27 35 61 124 2 1 62 562 2 5 58 1485912 7 33 39 41 43 45 51 61 888 1 18 774 3 18 39 55 98...
output:
3 3 3 2 2 3 2 2 3 2 2 2 2 2 3 2 3 2 3 3 2 3 2 3 2 2 2 1 3 1 2 3 3 1 2 2 3 3 2 1 3 1 2 2 1 2 2 3 2 3 3 1 3 2 1 2 3 1 2 3 3 3 3 2 2 3 2 1 3 2 2 2 3 2 2 1 2 2 3 1 3 1 2 3 2 2 1 2 2 2 2 2 1 4 3 3 1 2 2 3 1 1 2 3 3 2 2 2 2 3 3 3 1 3 3 2 2 2 2 3 2 2 1 2 3 2 1 2 2 3 2 1 3 3 2 3 1 3 2 3 1 1 2 3 2 3 1 1 1 3 ...
result:
ok 262144 tokens
Test #11:
score: 0
Accepted
time: 3772ms
memory: 689784kb
input:
262144 450 3 9 26 35 31 2 22 60 85 2 43 55 234 2 12 60 263 2 2 51 21 2 11 37 460 1 8 2097150 2 19 50 1098 1 63 884736 2 21 57 199 2 13 37 1574144 3 22 48 50 1083 2 21 36 2097088 3 6 9 13 2097149 2 11 35 974 3 36 46 49 2097080 3 28 43 48 222 2 39 43 31 3 15 18 56 234 2 50 55 175 2 1 25 482 3 16 37 54...
output:
2 1 2 3 1 2 4 2 3 3 1 2 3 2 2 2 3 2 1 2 3 2 1 2 3 2 3 2 3 2 1 2 2 1 1 2 2 3 1 3 3 2 2 3 2 2 2 1 2 2 1 2 2 2 2 1 2 3 2 2 2 1 2 2 2 3 4 3 1 2 2 3 2 1 2 2 3 2 2 3 2 2 1 2 2 3 3 3 2 3 1 1 3 2 2 2 2 2 2 1 3 2 2 2 2 1 1 2 2 2 3 2 3 2 1 3 2 2 1 3 2 2 2 2 2 2 2 3 3 2 1 2 2 1 2 2 1 3 2 3 1 2 2 2 3 2 2 2 2 2 ...
result:
ok 262144 tokens
Test #12:
score: 0
Accepted
time: 3740ms
memory: 689128kb
input:
262144 672 2 53 63 1061 3 33 49 57 806208 1 57 170 2 7 28 976896 2 1 19 1723392 1 33 50 2 19 40 57 3 6 31 32 221 2 34 45 221 2 25 45 2097062 3 25 33 58 1757184 2 27 60 60 2 38 46 428032 8 21 23 25 35 45 47 61 63 88 2 34 39 1221120 1 42 183 2 26 52 259 2 23 50 1096 5 7 10 22 38 44 179 2 61 63 76 8 20...
output:
2 1 3 3 3 2 3 2 2 2 3 3 2 2 2 3 2 2 2 1 2 3 3 2 2 3 2 2 2 3 3 3 1 2 2 2 1 3 2 2 1 2 2 3 2 2 2 2 2 1 2 3 2 2 2 3 2 1 3 2 2 2 2 2 2 1 1 2 2 2 2 3 3 2 2 2 2 2 3 1 2 2 2 3 3 3 2 3 4 2 3 2 2 2 2 2 2 3 2 3 2 1 2 2 3 3 3 1 1 3 3 3 3 2 2 3 2 2 1 3 3 3 2 3 1 2 3 2 3 3 3 4 2 3 1 2 3 2 2 3 2 2 1 2 3 2 1 2 3 2 ...
result:
ok 262144 tokens
Test #13:
score: 0
Accepted
time: 3715ms
memory: 689320kb
input:
262144 1757479 1 37 2044621 8 33 37 41 43 51 57 61 63 1833763 7 33 37 39 43 49 55 57 1335647 1 35 1219433 2 37 45 1852171 7 17 21 39 41 47 49 63 1272281 6 35 47 49 55 59 61 1061129 1 41 1820629 2 43 59 1950323 1 59 580471 1 37 1555907 2 17 55 657707 3 36 41 59 1937917 5 19 31 32 34 51 1397861 3 33 5...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 262144 tokens
Test #14:
score: 0
Accepted
time: 3700ms
memory: 689316kb
input:
262144 475249 7 37 45 51 53 57 61 63 849074 7 36 38 40 41 46 53 56 1457041 4 23 25 47 49 989474 1 35 75121 1 49 1966457 1 37 729033 4 33 37 41 63 1793533 1 51 1997439 4 33 43 57 59 233986 2 33 43 1658191 6 1 15 21 37 47 51 191206 6 13 41 43 55 59 63 1580539 4 41 42 46 61 881501 1 37 1107065 8 33 43 ...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 262144 tokens
Test #15:
score: 0
Accepted
time: 3787ms
memory: 688980kb
input:
262144 1780798 1 49 1789949 8 33 35 39 43 47 53 55 63 2046821 7 17 33 39 45 47 61 63 1223889 5 1 39 43 49 59 1342617 3 33 39 53 1931975 5 39 41 43 59 61 1883454 8 35 38 40 43 45 53 54 56 530049 1 47 2031474 4 35 41 53 57 1915235 1 39 94030 3 47 51 57 985970 3 29 57 63 138515 5 5 19 23 33 45 1879066 ...
output:
2 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 2 3 3 3 2 2 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 2 3 3 3 2 3 3 2 3 3 3 3 2 3 3 3 3 3 2 3 3 3 3 2 3 3 3 2 3 3 3 3 3 2 3 3 3 3 3 2 3 3 2 3 2 3 3 2 2 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 2 3 3 3 3 2 2 3 3 3 3 3 ...
result:
ok 262144 tokens
Test #16:
score: 0
Accepted
time: 3872ms
memory: 689116kb
input:
262144 29272 1 55 1899573 3 36 40 56 1694145 5 46 51 56 57 61 1507390 4 35 47 57 59 1913469 3 57 59 63 1830846 2 41 50 1638766 3 35 43 47 1037738 5 33 41 47 59 63 1635590 7 37 39 43 47 51 53 55 742743 8 37 39 41 47 51 57 59 61 1486070 7 33 35 41 43 47 53 59 1094196 3 41 51 55 900604 3 43 45 49 37847...
output:
3 3 3 3 3 3 3 2 2 3 2 3 3 3 3 4 3 3 3 2 3 2 3 3 2 3 3 3 3 3 3 4 3 4 3 4 4 3 3 2 3 3 2 3 2 2 2 3 3 2 3 2 3 3 2 3 3 3 2 2 3 4 3 3 3 2 3 2 2 2 3 3 3 3 2 3 3 3 2 2 3 4 3 3 4 3 2 3 2 2 3 2 4 2 2 3 2 3 4 3 2 3 3 4 4 2 4 2 4 3 2 3 4 3 2 3 3 2 3 3 4 3 3 4 3 4 3 3 3 3 3 4 3 3 3 2 3 2 2 2 3 2 4 2 3 2 2 3 2 3 ...
result:
ok 262144 tokens
Test #17:
score: 0
Accepted
time: 3867ms
memory: 689872kb
input:
262144 1750554 1 45 283311 8 37 41 43 47 51 55 57 59 157339 1 43 1567436 4 41 43 49 59 1529380 1 37 525182 2 33 41 1927140 4 33 44 57 58 1579525 3 45 51 55 1969374 7 33 35 43 45 51 57 63 1726242 3 7 11 27 985308 2 41 61 140568 7 33 35 43 55 57 59 61 1477422 1 33 1484632 7 39 41 45 47 59 61 63 196828...
output:
3 3 4 3 3 3 3 3 2 2 3 2 3 2 3 2 4 2 3 2 3 2 2 2 3 2 3 2 3 3 3 4 4 2 2 2 3 3 3 4 2 2 3 2 3 4 2 3 3 3 2 3 2 2 3 2 3 3 4 3 2 3 3 3 4 3 3 2 3 2 3 3 3 3 4 3 3 3 3 3 2 2 3 3 3 4 2 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 2 3 2 3 4 2 2 2 3 3 3 4 3 2 3 3 3 3 3 2 2 3 3 3 2 2 4 2 3 3 3 3 3 3 2 3 3 2 2 2 3 4 4 2 3 2 ...
result:
ok 262144 tokens
Test #18:
score: 0
Accepted
time: 3742ms
memory: 689288kb
input:
262144 1575517 8 37 43 49 51 55 57 61 63 1409957 8 37 45 53 55 57 59 61 63 1288769 8 37 41 43 47 49 51 57 59 1929607 8 33 35 41 43 55 57 59 63 1896331 8 37 41 47 51 53 57 61 63 473009 8 8 16 21 23 32 45 53 61 287821 8 35 39 43 45 47 49 57 61 732889 8 39 40 51 52 53 55 59 64 1430089 8 35 39 41 45 49 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 ...
result:
ok 262144 tokens
Test #19:
score: 0
Accepted
time: 3743ms
memory: 689332kb
input:
262144 2068397 8 35 41 43 49 51 55 59 61 2007935 8 41 43 45 49 51 53 57 59 1484547 8 33 35 38 43 45 49 52 53 1382969 8 33 35 37 41 45 49 53 59 2002379 8 3 17 19 33 35 47 57 61 2043139 8 17 19 29 33 51 53 55 63 2085239 8 33 35 39 47 55 57 59 61 1781797 8 37 41 43 45 47 53 57 59 1220721 8 33 35 41 45 ...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 262144 tokens
Test #20:
score: 0
Accepted
time: 3797ms
memory: 689140kb
input:
262144 1540382 5 8 22 35 38 41 1075954 1 9 315357 1 9 1753332 2 8 35 1740559 2 8 50 1655255 2 36 62 950813 1 21 1362719 1 7 1663869 6 1 6 13 32 61 62 1743262 4 9 24 26 57 1842557 2 7 55 810834 5 14 17 21 52 56 1835988 3 26 27 34 1653549 1 41 642676 2 20 21 944378 4 17 23 34 56 1957034 3 21 54 55 191...
output:
2 3 3 2 2 3 1 1 2 2 1 3 3 3 3 2 3 1 3 2 3 2 2 3 2 4 2 2 1 3 2 3 3 2 2 3 3 2 3 4 2 3 3 2 3 3 3 2 2 1 3 3 2 1 3 3 3 3 3 3 1 2 2 2 3 2 3 2 1 3 2 3 3 2 2 3 3 3 2 3 1 1 3 3 3 3 2 2 3 3 3 2 3 2 2 3 3 3 3 3 2 2 3 3 2 2 4 3 2 3 3 3 3 1 2 3 2 3 3 3 3 1 2 3 2 3 4 2 2 2 1 2 3 3 2 3 3 3 2 3 3 2 3 2 3 1 3 2 2 3 ...
result:
ok 262144 tokens
Test #21:
score: 0
Accepted
time: 3810ms
memory: 689588kb
input:
262141 1765576 1 5 995873 2 21 30 894245 4 1 11 23 26 893593 5 3 13 14 27 32 1717612 1 5 413456 2 17 28 295956 3 15 27 32 356817 3 20 22 29 65121 5 11 13 14 15 18 893840 3 5 16 18 203629 2 20 21 928467 3 4 12 15 612032 1 14 1163038 2 10 23 1992866 1 18 255902 3 17 21 29 146825 1 7 531108 3 1 8 22 18...
output:
3 2 3 2 3 3 2 3 2 3 2 3 3 3 3 2 3 3 3 3 3 1 2 1 1 3 3 2 3 3 2 2 2 3 2 3 2 3 3 1 2 3 2 3 3 3 3 2 3 3 3 2 2 3 1 3 2 2 3 2 3 3 2 2 4 3 3 3 2 2 4 2 3 2 2 2 2 3 2 3 2 3 3 3 3 2 2 3 3 2 2 3 3 3 3 3 4 2 2 2 3 2 2 2 1 3 2 3 1 4 3 3 3 1 3 4 3 4 2 2 3 3 1 2 2 4 1 3 3 3 2 3 2 2 2 3 3 3 3 3 3 3 2 1 3 2 2 2 1 3 ...
result:
ok 262141 tokens
Test #22:
score: 0
Accepted
time: 3788ms
memory: 689180kb
input:
262142 2037564 4 33 53 54 63 697482 2 41 57 408390 1 34 1199739 5 34 40 46 50 58 938094 3 54 59 62 964319 7 45 50 52 55 56 59 62 214917 1 45 1308020 1 64 283389 1 46 117497 1 35 1034111 2 43 56 1667640 3 37 43 58 555910 6 44 47 48 49 62 63 1657795 1 50 206804 1 33 1788261 6 34 42 52 56 59 60 1057631...
output:
2 3 3 2 2 2 3 3 2 1 3 3 2 3 3 3 1 3 2 4 2 4 2 2 3 2 1 2 3 2 3 1 2 2 2 2 3 3 2 3 2 3 3 2 2 2 4 4 2 3 2 2 3 2 3 1 2 3 3 3 3 3 2 3 2 3 2 3 3 2 2 3 3 2 3 3 2 3 2 2 3 2 2 3 2 2 1 3 3 2 2 3 3 3 2 4 3 2 2 3 1 2 2 3 1 2 1 2 3 3 2 2 3 3 3 3 3 2 3 1 4 2 3 3 2 3 2 3 2 2 2 3 3 3 3 3 3 3 3 1 4 3 2 2 2 2 2 3 3 4 ...
result:
ok 262142 tokens
Test #23:
score: 0
Accepted
time: 3808ms
memory: 689448kb
input:
262141 471200 1 53 249329 4 35 41 59 61 450598 1 49 1096921 2 53 59 1421607 1 43 926740 2 33 59 1527280 4 41 47 57 59 344274 5 35 37 43 45 55 47512 2 39 49 36626 5 33 37 39 47 59 1155924 2 51 63 664099 2 35 55 972545 1 45 1416432 5 33 35 37 47 59 165306 3 49 51 61 1091065 1 53 1286366 2 33 59 288469...
output:
3 1 2 2 3 3 3 3 2 2 3 1 4 3 3 2 2 2 2 3 3 3 2 4 3 2 2 1 3 3 2 2 3 3 3 3 3 2 3 3 1 2 4 3 1 2 4 2 3 2 5 3 3 3 3 2 3 3 3 3 4 3 2 3 2 2 3 3 2 3 3 2 1 4 3 2 3 3 3 2 2 3 1 3 2 3 2 2 3 3 3 3 2 2 2 3 3 4 3 3 3 3 2 2 2 3 2 2 2 2 2 3 1 2 2 3 1 1 2 3 3 3 2 2 2 4 4 4 2 3 2 3 3 3 3 2 2 4 2 3 3 3 2 2 2 3 3 3 3 2 ...
result:
ok 262141 tokens
Test #24:
score: 0
Accepted
time: 3782ms
memory: 688844kb
input:
262140 1508641 7 28 31 34 36 43 61 62 1759322 7 1 22 34 37 48 57 62 329439 7 2 19 24 26 37 41 51 2082019 8 8 11 16 30 47 51 56 58 824802 7 6 18 24 31 35 38 59 1894470 7 8 15 24 26 31 39 57 787377 7 2 4 5 21 23 52 62 1242303 7 1 4 6 35 47 51 62 2082172 7 4 8 12 14 23 28 34 19868 8 9 23 27 35 36 40 46...
output:
3 2 3 1 2 2 2 2 2 2 2 2 3 1 3 3 2 3 2 2 2 2 3 2 2 1 3 3 1 3 3 3 2 3 2 3 2 2 2 3 2 2 2 2 2 3 2 1 2 2 2 3 1 3 3 3 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 1 2 1 3 2 2 3 2 3 1 2 2 2 3 2 2 2 1 2 1 2 2 1 3 1 1 2 3 2 2 3 2 2 1 2 2 2 2 2 2 2 3 3 2 2 3 2 2 3 3 2 2 2 3 2 3 2 3 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 ...
result:
ok 262140 tokens
Test #25:
score: 0
Accepted
time: 3823ms
memory: 689156kb
input:
262063 846837 4 20 37 53 55 907056 6 8 26 39 43 49 57 333809 2 29 35 734788 3 11 31 55 433196 4 15 31 58 64 57181 1 51 992982 5 15 20 24 29 61 236676 5 2 10 32 42 49 871320 3 22 48 60 761494 2 15 29 370290 6 5 13 32 40 60 62 897382 2 46 58 1005520 1 5 15551 6 1 7 20 27 46 63 303266 1 8 736582 2 35 4...
output:
2 3 3 2 3 2 3 2 3 3 3 2 3 1 3 3 3 3 4 2 3 3 3 3 2 2 2 2 2 3 2 1 3 3 3 2 2 2 3 3 3 2 2 2 2 2 3 4 3 2 3 2 2 1 3 3 2 3 2 2 2 3 3 2 1 3 2 2 4 3 2 3 2 2 3 1 2 2 3 3 3 2 3 3 2 2 1 2 3 3 3 3 2 3 2 2 3 3 1 3 3 2 2 2 1 3 2 2 2 3 3 2 2 3 2 3 2 3 3 2 2 2 2 3 2 3 2 2 2 2 2 3 3 1 3 3 2 4 2 2 3 2 3 4 2 2 2 3 2 2 ...
result:
ok 262063 tokens
Test #26:
score: 0
Accepted
time: 3858ms
memory: 689032kb
input:
262124 1846841 2 28 48 1919199 4 11 20 23 53 1083016 1 36 1155633 2 44 45 1278282 2 9 48 1860121 5 3 37 48 49 56 1886674 1 37 1073824 3 20 35 58 1923778 3 4 34 50 1355623 6 1 39 42 45 51 56 1751908 4 20 23 49 54 1153008 2 10 37 1453477 2 56 61 1721600 3 30 43 62 1666095 1 15 1214047 4 23 31 42 51 19...
output:
2 3 3 3 3 2 3 3 2 1 3 3 1 3 3 1 3 2 3 2 2 1 2 2 3 1 2 3 3 3 2 3 3 2 3 3 3 2 3 3 3 3 3 3 2 4 3 2 2 2 3 3 3 3 2 3 2 2 2 2 2 2 1 2 2 3 3 3 4 1 2 2 3 3 1 2 2 3 3 2 2 2 2 2 2 2 4 3 5 1 1 3 2 3 2 2 3 3 1 2 3 3 4 2 2 2 3 2 2 3 3 3 2 2 2 2 2 2 3 3 3 3 2 3 3 2 3 4 2 3 3 1 2 2 2 2 3 3 3 3 2 2 3 3 3 2 3 3 3 3 ...
result:
ok 262124 tokens
Test #27:
score: 0
Accepted
time: 3851ms
memory: 689084kb
input:
262133 1849834 1 6 75455 2 1 41 1323543 1 23 1331735 1 4 1585945 1 3 791053 1 62 1868546 1 63 1467670 2 40 52 244703 1 32 1243005 2 41 51 321897 1 43 915154 1 40 575914 1 49 328420 1 20 1704229 1 4 1246125 1 23 2025723 1 23 2014366 1 57 166168 2 1 17 1735167 1 36 588547 1 23 1375773 1 6 1942224 1 27...
output:
3 2 3 3 2 1 3 3 1 4 3 3 3 3 1 4 4 2 2 4 2 3 3 2 3 3 2 2 3 3 2 2 1 4 3 3 3 4 3 3 3 2 3 3 3 3 4 4 2 2 2 3 2 2 3 2 4 3 3 3 2 3 2 3 2 2 3 2 2 3 4 4 3 3 4 3 4 4 2 3 3 2 3 2 4 1 3 3 3 3 3 2 2 2 4 3 3 3 4 2 3 2 4 4 1 3 3 4 3 2 3 2 3 4 3 2 2 2 3 3 2 1 4 4 3 3 2 3 3 3 4 1 2 1 3 3 3 3 3 3 4 3 2 3 3 3 3 2 2 2 ...
result:
ok 262133 tokens
Test #28:
score: 0
Accepted
time: 4233ms
memory: 689112kb
input:
262143 1197576 6 9 38 42 59 62 64 456036 3 28 29 39 429870 2 46 54 1032784 6 27 31 39 40 41 50 1533936 6 11 32 47 49 51 57 1464528 4 7 24 48 59 506175 6 29 31 34 39 45 61 611760 3 26 28 38 1954620 3 16 25 56 2066324 6 13 17 22 28 35 47 846832 6 8 14 20 38 56 64 873639 6 5 11 17 21 46 47 176988 5 15 ...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok 262143 tokens
Test #29:
score: 0
Accepted
time: 4340ms
memory: 689032kb
input:
262143 667032 7 2 27 34 37 41 51 59 1329732 7 12 25 37 38 41 50 51 555148 7 23 43 47 53 54 56 63 577449 7 3 5 41 52 53 55 63 521696 7 14 28 34 35 44 45 48 1830888 7 9 29 30 35 43 58 63 1916352 7 17 23 36 37 43 47 57 871792 7 2 5 25 38 41 57 61 1996544 7 17 19 31 40 47 58 64 1066268 7 4 18 21 35 40 4...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok 262143 tokens
Test #30:
score: 0
Accepted
time: 4470ms
memory: 689928kb
input:
262143 269240 8 25 29 37 40 43 50 57 64 691540 8 1 23 24 40 47 56 57 59 1779320 8 4 8 27 28 31 41 49 59 1124648 8 1 16 28 31 46 49 59 61 1392024 8 3 14 19 25 26 31 45 47 394821 8 1 3 11 13 23 29 49 50 648464 8 10 29 31 32 43 52 53 59 1361325 8 11 15 43 44 45 53 55 57 332992 8 10 21 28 29 37 45 52 61...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok 262143 tokens
Test #31:
score: 0
Accepted
time: 3890ms
memory: 689356kb
input:
262143 1461825 3 11 23 49 1181568 1 58 729306 1 15 1483160 1 36 1674808 1 20 825632 3 19 22 57 813967 3 5 32 41 710040 1 2 35144 1 5 898821 1 63 136125 1 37 560600 1 64 368433 1 45 1885580 1 29 429375 2 17 29 932496 1 47 1819827 3 5 27 53 1671390 1 45 343860 1 9 1979955 1 60 298035 3 5 23 43 1139944...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok 262143 tokens
Extra Test:
score: 0
Extra Test Passed