#line 1 "No_213_\u7d20\u6570\u30b5\u30a4\u30b3\u30ed\u3068\u5408\u6210\u6570\u30b5\u30a4\u30b3\u30ed_3_Easy.cpp" #define YRSD #line 2 "YRS/all.hpp" #line 2 "YRS/aa/head.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TE template #define TES template #define Z auto #define ep emplace_back #define eb emplace #define fi first #define se second #define all(x) (x).begin(), (x).end() #define ov(a, b, c, d, e, ...) e #define FO1(a) for (int _ = 0; _ < (a); ++_) #define FO2(i, a) for (int i = 0; i < (a); ++i) #define FO3(i, a, b) for (int i = (a); i < (b); ++i) #define FO4(i, a, b, c) for (int i = (a); i < (b); i += (c)) #define FOR(...) ov(__VA_ARGS__, FO4, FO3, FO2, FO1)(__VA_ARGS__) #define FF1(a) for (int _ = (a) - 1; _ >= 0; --_) #define FF2(i, a) for (int i = (a) - 1; i >= 0; --i) #define FF3(i, a, b) for (int i = (b) - 1; i >= (a); --i) #define FF4(i, a, b, c) for (int i = (b) - 1; i >= (a); i -= (c)) #define FOR_R(...) ov(__VA_ARGS__, FF4, FF3, FF2, FF1)(__VA_ARGS__) #define FOR_subset(t, s) for (int t = (s); t > -1; t = (t == 0 ? -1 : (t - 1) & s)) #define sort ranges::sort using namespace std; TE using vc = vector; TE using vvc = vc>; TE using T1 = tuple; TE using T2 = tuple; TE using T3 = tuple; TE using T4 = tuple; TE using max_heap = priority_queue; TE using min_heap = priority_queue, greater>; using u8 = unsigned char; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; using i128 = __int128; using u128 = __uint128_t; using f128 = __float128; using u16 = uint16_t; using PII = pair; using PLL = pair; #ifdef YRSD constexpr bool dbg = 1; #else constexpr bool dbg = 0; #endif #line 2 "YRS/IO/IO.hpp" istream &operator>>(istream &I, i128 &x) { static string s; I >> s; int f = s[0] == '-'; x = 0; const int N = (int)s.size(); FOR(i, f, N) x = x * 10 + s[i] - '0'; if (f) x = -x; return I; } ostream &operator<<(ostream &O, i128 x) { static string s; s.clear(); bool f = x < 0; if (f) x = -x; while (x) s += '0' + x % 10, x /= 10; if (s.empty()) s += '0'; if (f) s += '-'; reverse(all(s)); return O << s; } istream &operator>>(istream &I, f128 &x) { static string s; I >> s, x = stold(s); return I; } ostream &operator<<(ostream &O, const f128 x) { return O << ld(x); } template istream &operator>>(istream &I, tuple &t) { return apply([&I](Z &...s) { ((I >> s), ...); }, t), I; } template istream &operator>>(istream &I, pair &x) { return I >> x.fi >> x.se; } template ostream &operator<<(ostream &O, const pair &x) { return O << x.fi << ' ' << x.se; } TE requires requires(T &c) { begin(c); end(c); } and (not is_same_v, string>) istream &operator>>(istream &I, T &c) { for (Z &e : c) I >> e; return I; } TE requires requires(const T &c) { begin(c); end(c); } and (not is_same_v, const char*>) and (not is_same_v, string>) and (not is_array_v> or not is_same_v>, char>) ostream &operator<<(ostream &O, const T &a) { if (a.empty()) return O; Z i = a.begin(); O << *i++; for (; i != a.end(); ++i) O << ' ' << *i; return O; } void IN() {} TE void IN(T &x, Z &...s) { cin >> x, IN(s...); } void print() { cout << '\n'; } TES void print(T &&x, S &&...y) { cout << x; if constexpr (sizeof...(S)) cout << ' '; print(forward(y)...); } void put() {} TES void put(T &&x, S &&...y) { cout << x; put(forward(y)...); } #define INT(...) int __VA_ARGS__; IN(__VA_ARGS__) #define UINT(...) uint __VA_ARGS__; IN(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__) #define ULL(...) ull __VA_ARGS__; IN(__VA_ARGS__) #define I128(...) i128 __VA_ARGS__; IN(__VA_ARGS__) #define STR(...) string __VA_ARGS__; IN(__VA_ARGS__) #define CH(...) char __VA_ARGS__; IN(__VA_ARGS__) #define REAL(...) re __VA_ARGS__; IN(__VA_ARGS__) #define VEC(T, a, n) vc a(n); IN(a) void YES(bool o = 1) { print(o ? "YES" : "NO"); } void Yes(bool o = 1) { print(o ? "Yes" : "No"); } void yes(bool o = 1) { print(o ? "yes" : "no"); } void NO(bool o = 1) { YES(not o); } void No(bool o = 1) { Yes(not o); } void no(bool o = 1) { yes(not o); } void ALICE(bool o = 1) { print(o ? "ALICE" : "BOB"); } void Alice(bool o = 1) { print(o ? "Alice" : "Bob"); } void alice(bool o = 1) { print(o ? "alice" : "bob"); } void BOB(bool o = 1) { ALICE(not o); } void Bob(bool o = 1) { Alice(not o); } void bob(bool o = 1) { alice(not o); } void POSSIBLE(bool o = 1) { print(o ? "POSSIBLE" : "IMPOSSIBLE"); } void Possible(bool o = 1) { print(o ? "Possible" : "Impossible"); } void possible(bool o = 1) { print(o ? "possible" : "impossible"); } void IMPOSSIBLE(bool o = 1) { POSSIBLE(not o); } void Impossible(bool o = 1) { Possible(not o); } void impossible(bool o = 1) { possible(not o); } void TAK(bool o = 1) { print(o ? "TAK" : "NIE"); } void NIE(bool o = 1) { TAK(not o); } #line 5 "YRS/all.hpp" #if (__cplusplus >= 202002L) #include constexpr ld pi = numbers::pi_v; #endif TE constexpr T inf = numeric_limits::max(); template <> constexpr i128 inf = i128(inf) * 2'000'000'000'000'000'000; template constexpr pair inf> = {inf, inf}; TE constexpr static inline int pc(T x) { return popcount(make_unsigned_t(x)); } constexpr static inline ll len(const Z &a) { return a.size(); } void reverse(Z &a) { reverse(all(a)); } void unique(Z &a) { sort(a); a.erase(unique(all(a)), a.end()); } TE vc inverse(const vc &a) { int N = len(a); vc b(N, -1); FOR(i, N) if (a[i] != -1) b[a[i]] = i; return b; } Z QMAX(const Z &a) { return *max_element(all(a)); } Z QMIN(const Z &a) { return *min_element(all(a)); } TE Z QMAX(T l, T r) { return *max_element(l, r); } TE Z QMIN(T l, T r) { return *min_element(l, r); } constexpr bool chmax(Z &a, const Z &b) { return (a < b ? a = b, 1 : 0); } constexpr bool chmin(Z &a, const Z &b) { return (a > b ? a = b, 1 : 0); } vc argsort(const Z &a) { vc I(len(a)); iota(all(I), 0); sort(I, [&](int i, int k) { return a[i] < a[k] or (a[i] == a[k] and i < k); }); return I; } TE vc rearrange(const vc &a, const vc &I) { int N = len(I); vc b(N); FOR(i, N) b[i] = a[I[i]]; return b; } template vc pre_sum(const vc &a) { int N = len(a); vc c(N + 1); FOR(i, N) c[i + 1] = c[i] + a[i]; if (of == 0) c.erase(c.begin()); return c; } TE constexpr static int topbit(T x) { if (x == 0) return - 1; if constexpr (sizeof(T) <= 4) return 31 - __builtin_clz(x); else return 63 - __builtin_clzll(x); } TE constexpr static int lowbit(T x) { if (x == 0) return -1; if constexpr (sizeof(T) <= 4) return __builtin_ctz(x); else return __builtin_ctzll(x); } TE constexpr T floor(T x, T y) { return x / y - (x % y and (x ^ y) < 0); } TE constexpr T ceil(T x, T y) { return floor(x + y - 1, y); } TE constexpr T bmod(T x, T y) { return x - floor(x, y) * y; } TE constexpr pair divmod(T x, T y) { T q = floor(x, y); return pair{q, x - q * y}; } template T SUM(const Z &v) { return accumulate(all(v), T(0)); } int lb(const Z &a, Z x) { return lower_bound(all(a), x) - a.begin(); } TE int lb(T l, T r, Z x) { return lower_bound(l, r, x) - l; } int ub(const Z &a, Z x) { return upper_bound(all(a), x) - a.begin(); } TE int ub(T l, T r, Z x) { return upper_bound(l, r, x) - l; } template ll bina(Z f, ll l, ll r) { if constexpr (ck) assert(f(l)); while (abs(l - r) > 1) { ll x = (r + l) >> 1; (f(x) ? l : r) = x; } return l; } TE T bina_real(Z f, T l, T r, int c = 100) { while (c--) { T x = (l + r) / 2; (f(x) ? l : r) = x; } return (l + r) / 2; } Z pop(Z &s) { if constexpr (requires { s.pop_back(); }) { Z x = s.back(); return s.pop_back(), x; } else if constexpr (requires { s.top(); }) { Z x = s.top(); return s.pop(), x; } else { Z x = s.front(); return s.pop(), x; } } void setp(int x) { cout << fixed << setprecision(x); } TE inline void sh(vc &a, int N, T b = {}) { a.resize(N, b); } #line 1 "YRS/debug.hpp" #ifdef YRSD void DBG() { cerr << "]" << endl; } TES void DBG(T &&x, S &&...y) { cerr << x; if constexpr (sizeof...(S)) cerr << ", "; DBG(forward(y)...); } #define debug(...) cerr << "[" << __LINE__ << "]: [" #__VA_ARGS__ "] = [", DBG(__VA_ARGS__) void ERR() { cerr << endl; } TES void ERR(T &&x, S &&...y) { cerr << x; if constexpr (sizeof...(S)) cerr << ", "; ERR(forward(y)...); } #define err(...) cerr << "[" << __LINE__ << "]: ", ERR(__VA_ARGS__) #define asser assert #else #define debug(...) void(0721) #define err(...) void(0721) #endif #line 2 "YRS/poly/fps_pow.hpp" #line 2 "YRS/poly/fps_log.hpp" #line 2 "YRS/poly/c/bs.hpp" #line 2 "YRS/poly/c/fps_t.hpp" #line 2 "YRS/mod/mint_t.hpp" #define c constexpr template struct mint_t { using T = mint_t; static c uint m = mod; uint x; c inline uint val() const { return x; } c mint_t() : x(0) {} c mint_t(uint x) : x(x % m) {} c mint_t(ull x) : x(x % m) {} c mint_t(u128 x) : x(x % m) {} c mint_t(int x) : x((x %= mod) < 0 ? x + mod : x) {} c mint_t(ll x) : x((x %= mod) < 0 ? x + mod : x) {} c mint_t(i128 x) : x((x %= mod) < 0 ? x + mod : x) {} c T &operator+=(T p) { if ((x += p.x) >= m) x -= m; return *this; } c T &operator-=(T p) { if ((x += m - p.x) >= m) x -= m; return *this; } c T operator+(T p) const { return T(*this) += p; } c T operator-(T p) const { return T(*this) -= p; } c T &operator*=(T p) { x = ull(x) * p.x % m; return *this; } c T operator*(T p) const { return T(*this) *= p; } c T &operator/=(T p) { return *this *= p.inv(); } c T operator/(T p) const { return T(*this) /= p; } c T operator-() const { return T::gen(x ? mod - x : 0); } c T inv() const { int a = x, b = mod, x = 1, y = 0; while (b > 0) { int t = a / b; swap(a -= t * b, b); swap(x -= t * y, y); } return T(x); } c T pow(ll k) const { if (k < 0) return inv().pow(-k); T s(1), a(x); for (; k; k >>= 1, a *= a) if (k & 1) s *= a; return s; } c bool operator<(T p) const { return x < p.x; } c bool operator==(T p) const { return x == p.x; } c bool operator!=(T p) const { return x != p.x; } static c T gen(uint x) { T s; s.x = x; return s; } friend istream &operator>>(istream &cin, T &p) { ll t; cin >> t; p = t; return cin; } friend ostream &operator<<(ostream &cout, T p) { return cout << p.x; } static c int get_mod() { return mod; } static c PII ntt_info() { if (mod == 167772161) return {25, 17}; if (mod == 469762049) return {26, 30}; if (mod == 754974721) return {24, 362}; if (mod == 998244353) return {23, 31}; if (mod == 120586241) return {20, 74066978}; if (mod == 880803841) return {23, 211}; if (mod == 943718401) return {22, 663003469}; if (mod == 1004535809) return {21, 582313106}; if (mod == 1012924417) return {21, 368093570}; return {-1, -1}; } static c bool can_ntt() { return ntt_info().fi != -1; } }; #undef c using M99 = mint_t<998244353>; using M17 = mint_t<1000000007>; using M11 = M17; #ifdef FIO template void rd(mint_t &x) { LL(y); x = y; } template void wt(mint_t x) { wt(x.x); } #endif #line 4 "YRS/poly/c/fps_t.hpp" // 动态模数需要在 设置模数后 进行构造 TE struct fps_t { using fps = vc; using cf = const fps &; static inline const uint p = T::get_mod(), t = T::ntt_info().fi, r = T::ntt_info().se; static inline const ull M = ull(p) * p; // 需要动态模数反复set mod的啥比题到底是谁在出 // static inline uint p = T::get_mod(), t = T::ntt_info().fi, // r = T::ntt_info().se; // static inline ull M = ull(p) * p; // static void reset() { // p = T::get_mod(); // tie(t, r) = T::ntt_info(); // M = ull(p) * p; // } fps fa{1, 1}, ifa{1, 1}, in{0, 1}; T inv(int); T fac(int); T ifac(int); T C(int, int); static constexpr int p0 = 167'772'161, p1 = 469'762'049, p2 = 754'974'721; using f0 = fps_t>; using f1 = fps_t>; using f2 = fps_t>; static void sh(fps &, int); static int count_terms(cf); static T eval(cf, T); T crt(ull, ull, ull); u128 crt_128(ull, ull, ull); static void ntr(T *, T *, T *, T *, T *, T *); static void ntt(fps &, bool); static void trans_ntt(fps &, bool); static void ntt_db(fps &f, bool = 0); fps conv_naive(cf, cf); fps conv_kara(cf, cf); static fps conv_ntt(fps, fps); fps conv_mtt(cf, cf); fps conv(cf, cf); vc conv_for_big(const vc &, const vc &); static fps sq_ntt(fps); fps sq_mtt(cf); fps sq(cf); fps diff(cf); fps inte(cf); T inte(cf, T, T); fps mid_prod(cf, cf); fps inv_sp(cf); fps inv_ntt(cf); fps inv_mtt(cf); fps inv(cf); fps div_sp(fps, fps); fps div_ntt(cf, cf); fps div_mtt(fps, fps); fps div_dense(cf, cf); fps div(cf, cf); fps log_sp(cf); fps log_dense(cf); fps log(cf); fps exp_sp(cf); fps exp_ntt(cf); fps exp_mtt(cf); fps exp_dense(cf); fps exp(cf); fps pw_sp(cf, T); fps pw_dense(cf, T); fps pw(cf, T); fps pow(cf, ll); fps sqr_sp(cf); fps sqr_ntt(cf); fps sqr_dense(cf); fps sqr(cf); fps sqrt(cf); fps conv_all(const vc &); fps conv_all(fps); fps eval_geo(fps, T, T, int); fps inte_geo(fps, T, T); struct subprod_t; subprod_t subprod(cf); fps eval_ntt(fps, fps); fps eval(fps, fps); fps inte(fps, fps); fps shift(fps, T); T lag(cf, T); fps lag(cf, T, int); T lag(cf, cf, T); fps pow_proj_ntt(fps, fps, int); fps pow_proj(fps, fps, int); fps comp_slow(cf, cf); fps comp_ntt(fps, fps); fps comp_mtt(fps, fps); fps comp(fps, fps); fps comp_inv(fps); pair divmod(fps, cf); fps modpow(cf, ll, cf); fps prod_of_f_rk_x(fps, T, int); fps prod_of_one_minus_xn(const vc &, int); fps prod_of_inv_one_minus_xn(const vc &, int); fps prod_of_one_plus_xn(const vc &a, int); fps prod_of_inv_one_plus_xn(const vc &a, int); pair sum_of_rationals(vc>); pair sum_of_rationals_sp(cf, cf); fps sum_of_exp_bx(cf, cf, int); fps sum_of_pow(cf, int); fps sum_of_pow(ll, ll, int); fps sum_of_pow(cf, cf, int); fps sum_of_binomail(fps, T, T); fps subset_sum(const vc &, int k); fps subset_sum_lm(const vc &, int k); T coef_of_rationals_ntt(fps, fps, ll); T coef_of_rationals_mtt(fps, fps, ll); T coef_of_rationals(fps, fps, ll); fps coef_of_rationals(fps, fps, ll, ll); fps find_line(cf); T line_inte(cf a, ll N); template struct fac_t; template fac_t fac_large(); fps p_to_ffp(cf); fps ffp_to_p(cf); fps ffp_conv_ntt(fps, fps); fps ffp_conv_mtt(fps, fps); fps ffp_conv(cf, cf); fps sin(cf); fps cos(cf); fps asin(cf); fps atan(cf); fps comp_f_ex(cf); fps comp_f_1_minus_ex(cf); fps comp_f_ex_minus_1(cf); fps comp_f_a_plus_bx(cf, T, T); fps comp_f_aplusbx_div_cplusdx_fake(cf, T, T, T, T); fps comp_f_aplusbx_div_cplusdx(cf, T, T, T, T); fps comp_f_x_plus_1_divx(cf); struct conv_t; conv_t online_conv(); struct exp_t; exp_t online_exp(); struct log_t; log_t online_log(); struct inv_t; inv_t online_inv(); struct div_t; div_t online_div(); struct pow_t; pow_t online_pow(T); fps presum(cf, T); fps sinh(int); fps exp_x(int); fps exp_invx(int); fps E_S(int); fps E(int); fps E_n(int, int); fps E_odd(int); fps E_noempty(int); fps C_R(int); fps bell(int); fps derange(int); fps bernoulli(int); fps partition(int); fps count_label_dag(int); fps count_label_dag_con(int); fps count_label_undir(int); fps count_label_undir_con(int); fps count_label_unicycle(int); fps count_label_bipartite(int, bool); fps count_label_bcc_v(int); T count_label_bcc_v_N(int); fps count_label_bcc_e(int); T count_label_bcc_e_N(int); T count_label_tournament(int); fps count_label_scc(int); fps count_label_euler_undir(int); fps count_label_tree(int); fps count_unlabel_tree(int); }; #line 4 "YRS/poly/c/bs.hpp" TE Z fps_t::inv(int n) -> T { assert(0 <= n); while (len(in) <= n) { int k = len(in), q = (p + k - 1) / k, r = k * q - p; in.ep(in[r] * T(q)); } return in[n]; } TE Z fps_t::fac(int n) -> T { if (n >= p) return 0; while (len(fa) <= n) { int k = len(fa); fa.ep(fa[k - 1] * T(k)); } return fa[n]; } TE Z fps_t::ifac(int n) -> T { if (n < 0) return T(0); while (len(ifa) <= n) ifa.ep(ifa.back() * inv(len(ifa))); return ifa[n]; } TE Z fps_t::C(int n, int k) -> T { assert(n >= 0); if (k < 0 or n < k) return 0; return fac(n) * ifac(k) * ifac(n - k); } TE Z fps_t::sh(fps &a, int N) -> void { a.resize(N); } // 非0项数量 TE Z fps_t::count_terms(cf f) -> int { int s = 0, N = len(f); FOR(i, N) s += f[i].val() != 0; return s; } TE Z fps_t::eval(cf f, T x) -> T { T s = 0, c = 1; int N = len(f); FOR(i, N) s += f[i] * c, c *= x; return s; } TE Z fps_t::crt(ull a, ull b, ull c) -> T { constexpr ull x = 104'391'568, xx = 190'329'765; ull t = (b - a + p1) * x % p1, s = a + t * p0; t = (c - s % p2 + p2) * xx % p2; return T(s) + T(t) * T(ull(p0) * p1); } TE Z fps_t::ntr(T *w, T *iw, T *r, T *ir, T *b, T *ib) -> void { w[t] = fps_t::r, iw[t] = w[t].inv(); FOR_R(i, t) w[i] = w[i + 1] * w[i + 1], iw[i] = iw[i + 1] * iw[i + 1]; T s = 1, c = 1; #define f(a, g) FOR(i, t - g + 1) a[i] = w[i + g] * s, s *= iw[i + g], i##a[i] = iw[i + g] * c, c *= w[i + g] f(r, 2); s = c = 1; f(b, 3); #undef f } TE Z fps_t::ntt(fps &a, bool in) -> void { assert(T::can_ntt()); const uint m = p; static T w[30], iw[30], r[30], ir[30], b[30], ib[30]; static bool ok = 0; if (ok == 0) ok = 1, ntr(w, iw, r, ir, b, ib); #define f(k) a[i + of + k * p] #define g(k) ull(f(k).val()) #define tp topbit(~s & -~s) int N = len(a), n = topbit(N); if (not in) { int sz = 0; while (sz < n) { if (n - sz == 1) { int p = 1 << (n - sz - 1); T c = 1; FOR(s, 1 << sz) { int of = s << (n - sz); FOR(i, p) { T l = f(0), w = f(1) * c; f(0) = l + w, f(1) = l - w; } c *= r[tp]; } ++sz; } else { int p = 1 << (n - sz - 2); T c = 1, in = w[2]; FOR(s, 1 << sz) { T rr = c * c, R = rr * c; int of = s << (n - sz); FOR(i, p) { ull x = g(0), y = g(1) * c.val(), e = g(2) * rr.val(), r = g(3) * R.val(), t = (y + M - r) % m * in.val(); f(0) = x + y + e + r; f(1) = x + e + M + M - y - r; f(2) = x + M - e + t; f(3) = x + M + M - e - t; } c *= b[tp]; } sz += 2; } } } else { T c = T(N).inv(); FOR(i, N) a[i] *= c; int sz = n; while (sz) { if (sz == 1) { int p = 1 << (n - sz); T c = 1; FOR(s, 1 << (sz - 1)) { int of = s << (n - sz + 1); FOR(i, p) { ull l = g(0), r = g(1); f(0) = l + r, f(1) = (m + l - r) * c.val(); } c *= ir[tp]; } --sz; } else { int p = 1 << (n - sz); T c = 1, in = iw[2]; FOR(s, 1 << (sz - 2)) { T rr = c * c, R = rr * c; int of = s << (n - sz + 2); FOR(i, p) { ull x = g(0), y = g(1), e = g(2), r = g(3), t = (m + e - r) * in.val() % m; f(0) = x + y + e + r; f(1) = (x + m - y + t) * c.val(); f(2) = (x + y + m + m - e - r) * rr.val(); f(3) = (x + m + m - y - t) * R.val(); } c *= ib[tp]; } sz -= 2; } } } } #undef f #undef g #undef tp TE Z fps_t::conv_naive(cf a, cf b) -> fps { int N = len(a), M = len(b), sz = N + M - 1; if (not N or not M) return {}; if (N > M) return conv_naive(b, a); fps c(sz); FOR(i, N) FOR(k, M) c[i + k] += a[i] * b[k]; return c; } TE Z fps_t::conv_kara(cf f, cf g) -> fps { constexpr int lm = 30; if (min(len(f), len(g)) <= lm) return conv_naive(f, g); int N = max(len(f), len(g)), M = ceil(N, 2); fps f1, f2, g1, g2; if (len(f) < M) f1 = f; if (len(f) >= M) f1 = {f.begin(), f.begin() + M}; if (len(f) >= M) f2 = {f.begin() + M, f.end()}; if (len(g) < M) g1 = g; if (len(g) >= M) g1 = {g.begin(), g.begin() + M}; if (len(g) >= M) g2 = {g.begin() + M, g.end()}; fps a = conv_kara(f1, g1); fps b = conv_kara(f2, g2); FOR(i, len(f2)) f1[i] += f2[i]; FOR(i, len(g2)) g1[i] += g2[i]; fps c = conv_kara(f1, g1); fps F(len(f) + len(g) - 1); FOR(i, len(a)) F[i] += a[i], c[i] -= a[i]; FOR(i, len(b)) F[2 * M + i] += b[i], c[i] -= b[i]; if (c.back() == T(0)) c.pop_back(); FOR(i, len(c)) if (c[i] != T(0)) F[M + i] += c[i]; return F; } TE Z fps_t::conv_ntt(fps a, fps b) -> fps { assert(T::can_ntt()); int N = len(a), M = len(b), sz = 1; if (min(N, M) == 0) return {}; while (sz < N + M - 1) sz <<= 1; sh(a, sz), sh(b, sz); ntt(a, 0); ntt(b, 0); FOR(i, sz) a[i] *= b[i]; ntt(a, 1); sh(a, N + M - 1); return a; } TE Z fps_t::conv_mtt(cf a, cf b) -> fps { int N = len(a), M = len(b); if (not N or not M) return {}; f0::fps a0(N), b0(M); f1::fps a1(N), b1(M); f2::fps a2(N), b2(M); FOR(i, N) a0[i] = a[i].val(), a1[i] = a[i].val(), a2[i] = a[i].val(); FOR(i, M) b0[i] = b[i].val(), b1[i] = b[i].val(), b2[i] = b[i].val(); Z c0 = f0::conv_ntt(a0, b0); Z c1 = f1::conv_ntt(a1, b1); Z c2 = f2::conv_ntt(a2, b2); fps c(len(c0)); FOR(i, N + M - 1) c[i] = crt(c0[i].val(), c1[i].val(), c2[i].val()); return c; } TE Z fps_t::conv(cf a, cf b) -> fps { int N = len(a), M = len(b); if (min(N, M) == 0) return {}; if (T::can_ntt()) { if (min(N, M) <= 50) return conv_kara(a, b); return conv_ntt(a, b); } if (min(N, M) <= 200) return conv_kara(a, b); return conv_mtt(a, b); } TE Z fps_t::sq_ntt(fps a) -> fps { assert(T::can_ntt()); int N = len(a), sz = 1; if (N == 0) return {}; while (sz < N + N - 1) sz <<= 1; sh(a, sz); ntt(a, 0); FOR(i, sz) a[i] *= a[i]; ntt(a, 1); sh(a, N + N - 1); return a; } TE Z fps_t::sq_mtt(cf a) -> fps { int N = len(a); if (N == 0) return {}; f0::fps a0(N); f1::fps a1(N); f2::fps a2(N); FOR(i, N) a0[i] = a[i].val(), a1[i] = a[i].val(), a2[i] = a[i].val(); Z c0 = f0::sq_ntt(a0); Z c1 = f1::sq_ntt(a1); Z c2 = f2::sq_ntt(a2); fps c(len(c0)); FOR(i, N + N - 1) c[i] = crt(c0[i].val(), c1[i].val(), c2[i].val()); return c; } TE Z fps_t::sq(cf a) -> fps { int N = len(a); if (T::can_ntt()) { if (N <= 50) return conv_naive(a, a); return sq_ntt(a); } if (N <= 150) return conv_kara(a, a); return sq_mtt(a); } // 微分 TE Z fps_t::diff(cf f) -> fps { int N = len(f); if (N <= 1) return {}; fps g(N - 1); FOR(i, N - 1) g[i] = f[i + 1] * T(i + 1); return g; } // 积分 TE Z fps_t::inte(cf f) -> fps { int N = len(f); fps g(N + 1); FOR(i, 1, N + 1) g[i] = f[i - 1] * inv(i); return g; } // 定积分 TE Z fps_t::inte(cf f, T l, T r) -> T { T s = 0, L = 1, R = 1; int N = len(f); FOR(i, N) { L *= l, R *= r; s += inv(i + 1) * f[i] * (L - R); } return s; } #line 2 "YRS/poly/fps_div.hpp" #line 2 "YRS/poly/fps_inv.hpp" #line 4 "YRS/poly/fps_inv.hpp" TE Z fps_t::inv_sp(cf f) -> fps { int N = len(f); vc> a; FOR(i, 1, N) if (f[i] != T(0)) a.ep(i, f[i]); fps g(N); T t = T(1) / f[0]; g[0] = t; FOR(i, 1, N) { T s = 0; for (Z &&[x, y] : a) { if (x > i) break; s -= y * g[i - x]; } g[i] = s * t; } return g; } TE Z fps_t::inv_ntt(cf a) -> fps { fps s{T(1) / a[0]}; int N = len(a), n = 1; s.reserve(N); for (; n < N; n <<= 1) { fps f(n << 1), g(n << 1); int sz = min(N, n << 1); FOR(i, sz) f[i] = a[i]; FOR(i, n) g[i] = s[i]; ntt(f, 0); ntt(g, 0); FOR(i, n << 1) f[i] *= g[i]; ntt(f, 1); FOR(i, n) f[i] = 0; ntt(f, 0); FOR(i, n << 1) f[i] *= g[i]; ntt(f, 1); FOR(i, n, sz) s.ep(-f[i]); } return s; } TE Z fps_t::inv_mtt(cf a) -> fps { int N = len(a), n = 1; fps c{a[0].inv()}, p; for (; n < N; n <<= 1) { p = sq(c); sh(p, n << 1); fps f(begin(a), begin(a) + min(n << 1, N)); p = conv(p, f); sh(c, n << 1); FOR(i, n << 1) c[i] = c[i] + c[i] - p[i]; } sh(c, N); return c; } TE Z fps_t::inv(cf f) -> fps { int t = count_terms(f), c = T::can_ntt() ? 160 : 820; if (t < c) return inv_sp(f); return T::can_ntt() ? inv_ntt(f) : inv_mtt(f); } #line 5 "YRS/poly/fps_div.hpp" TE Z fps_t::div_sp(fps f, fps g) -> fps { if (g[0].val() != 1) { T c = g[0].inv(); for (T &x : f) x *= c; for (T &x : g) x *= c; } vc> a; int N = len(g); FOR(i, 1, N) if (g[i].val() != 0) a.ep(i, -g[i]); N = len(f); FOR(i, N) for (Z &&[x, y] : a) if (i >= x) f[i] += y * f[i - x]; return f; } TE Z fps_t::div_ntt(cf f, cf g) -> fps { int N = len(f), M = len(g); if (N == 1) return {f[0] / g[0]}; int m = 1; while (m + m < N) m <<= 1; fps a(m << 1), b(m << 1), c(g); sh(c, m); c = inv(c); sh(c, m << 1); ntt(c, 0); FOR(i, m) a[i] = f[i]; FOR(i, m, N) a[i] = 0; ntt(a, 0); FOR(i, m << 1) a[i] *= c[i]; ntt(a, 1); fps s(N); FOR(i, m) s[i] = a[i]; FOR(i, m, m << 1) a[i] = 0; ntt(a, 0); FOR(i, min(m << 1, M)) b[i] = g[i]; FOR(i, min(m << 1, M), m << 1) b[i] = 0; ntt(b, 0); FOR(i, m << 1) a[i] *= b[i]; ntt(a, 1); FOR(i, m) a[i] = 0; FOR(i, m, min(m << 1, N)) a[i] -= f[i]; ntt(a, 0); FOR(i, m << 1) a[i] *= c[i]; ntt(a, 1); FOR(i, m, N) s[i] -= a[i]; return s; } TE Z fps_t::div_mtt(fps f, fps g) -> fps { int N = len(f); sh(g, N); g = inv(g); f = conv(f, g); sh(f, N); return f; } TE Z fps_t::div_dense(cf f, cf g) -> fps { return T::can_ntt() ? div_ntt(f, g) : div_mtt(f, g); } TE Z fps_t::div(cf f, cf g) -> fps { if (count_terms(g) < 50) return div_sp(f, g); return T::can_ntt() ? div_ntt(f, g) : div_mtt(f, g); } #line 5 "YRS/poly/fps_log.hpp" TE Z fps_t::log_sp(cf f) -> fps { int N = len(f); vc> a; FOR(i, 1, N) if (f[i].val() != 0) a.ep(i, f[i]); fps b(N), c(N - 1); FOR(i, N - 1) { T s = f[i + 1] * T(i + 1); for (Z &&[x, y] : a) { if (x > i) break; s -= y * c[i - x]; } c[i] = s; b[i + 1] = s * inv(i + 1); } return b; } TE Z fps_t::log_dense(cf f) -> fps { assert(f[0] == T(1)); int N = len(f); fps c(f); FOR(i, N) c[i] *= i; c = div_dense(c, f); FOR(i, N) c[i] *= inv(i); return c; } TE Z fps_t::log(cf f) -> fps { assert(f[0] == T(1)); int c = count_terms(f), t = T::can_ntt() ? 200 : 1200; return c <= t ? log_sp(f) : log_dense(f); } #line 2 "YRS/poly/fps_exp.hpp" #line 4 "YRS/poly/fps_exp.hpp" TE Z fps_t::exp_sp(cf f) -> fps { int N = len(f); if (N == 0) return {T(1)}; assert(f[0].val() == 0); vc> a; FOR(i, 1, N) if (f[i].val() != 0) a.ep(i - 1, f[i] * T(i)); fps c(N); c[0] = 1; FOR(i, 1, N) { T s = 0; for (Z &&[x, y] : a) { if (x > i - 1) break; s += y * c[i - 1 - x]; } c[i] = s * inv(i); } return c; } TE Z fps_t::exp_ntt(cf f) -> fps { int N = len(f); assert(N > 0 and f[0].val() == 0); vc s{1, (N > 1 ? f[1] : 0)}, c{1}, a, b{1, 1}; while (len(s) < N) { int m = len(s); fps y = s; sh(y, m << 1); ntt(y, 0); a = b; vc z(m); FOR(i, m) z[i] = y[i] * a[i]; ntt(z, 1); FOR(i, m >> 1) z[i] = 0; ntt(z, 0); FOR(i, m) z[i] *= -a[i]; ntt(z, 1); c.insert(c.end(), z.begin() + m / 2, z.end()); b = c; sh(b, m << 1); ntt(b, 0); vc x(f.begin(), f.begin() + m); FOR(i, m - 1) x[i] = x[i + 1] * T(i + 1); x.back() = 0; ntt(x, 0); FOR(i, m) x[i] *= y[i]; ntt(x, 1); FOR(i, m - 1) x[i] -= s[i + 1] * T(i + 1); sh(x, m << 1); FOR(i, m - 1) x[m + i] = x[i], x[i] = 0; ntt(x, 0); FOR(i, m << 1) x[i] *= b[i]; ntt(x, 1); FOR_R(i, len(x) - 1) x[i + 1] = x[i] * inv(i + 1); x[0] = 0; FOR(i, m, min(N, m << 1)) x[i] += f[i]; FOR(i, m) x[i] = 0; ntt(x, 0); FOR(i, m << 1) x[i] *= y[i]; ntt(x, 1); s.insert(s.end(), x.begin() + m, x.end()); } sh(s, N); return s; } TE Z fps_t::exp_mtt(cf e) -> fps { fps h(e); int N = len(h), n = 0, m = 1; assert(N > 0 and h[0] == T(0)); while (1 << n < N) ++n; sh(h, 1 << n); Z dh = diff(h); fps f{1}, g{1}, p; FOR(n) { p = conv(f, g); sh(p, m); p = conv(p, g); sh(p, m); sh(g, m); FOR(i, m) g[i] += g[i] - p[i]; p = {dh.begin(), dh.begin() + m - 1}; p = conv(f, p); sh(p, m + m - 1); FOR(i, m + m - 1) p[i] = -p[i]; FOR(i, m - 1) p[i] += T(i + 1) * f[i + 1]; p = conv(p, g); sh(p, m + m - 1); FOR(i, m - 1) p[i] += dh[i]; p = inte(p); FOR(i, m << 1) p[i] = h[i] - p[i]; p[0] += T(1); f = conv(f, p); m <<= 1; sh(f, m); } sh(f, N); return f; } TE Z fps_t::exp_dense(cf f) -> fps { return T::can_ntt() ? exp_ntt(f) : exp_mtt(f); } TE Z fps_t::exp(cf f) -> fps { int n = count_terms(f), t = T::can_ntt() ? 320 : 3000; return n <= t ? exp_sp(f) : exp_dense(f); } #line 5 "YRS/poly/fps_pow.hpp" TE Z fps_t::pw_sp(cf f, T k) -> fps { int N = len(f); assert(N == 0 or f[0] == T(1)); vc> a; FOR(i, 1, N) if (f[i].val() != 0) a.ep(i, f[i]); vc g(N); g[0] = 1; FOR(i, N - 1) { T &s = g[i + 1]; for (Z &&[x, y] : a) { if (x > i + 1) break; T t = y * g[i - x + 1]; s += t * (k * T(x) - T(i - x + 1)); } s *= inv(i + 1); } return g; } TE Z fps_t::pw_dense(cf f, T k) -> fps { assert(f[0] == T(1)); fps g = log(f); int N = len(f); FOR(i, N) g[i] *= k; return exp(g); } TE Z fps_t::pw(cf f, T k) -> fps { int n = count_terms(f), t = T::can_ntt() ? 100 : 1300; return n <= t ? pw_sp(f, k) : pw_dense(f, k); } TE Z fps_t::pow(cf f, ll k) -> fps { assert(0 <= k); int N = len(f); if (k == 0) { fps g(N); g[0] = 1; return g; } if (f[0] == T(1)) return pw(f, T(k)); int d = N; FOR_R(i, N) if (f[i].val() != 0) d = i; if (d >= ceil(N, k)) return fps(N); int of = d * k; T c = f[d], in = c.inv(); fps g(N - of); FOR(i, N - of) g[i] = f[d + i] * in; g = pw(g, T(k)); fps s(N); c = c.pow(k); N = len(g); FOR(i, N) s[of + i] = g[i] * c; return s; } #line 2 "YRS/poly/coef_of_rationals.hpp" #line 2 "YRS/poly/poly_divmod.hpp" #line 4 "YRS/poly/poly_divmod.hpp" // {q, r} of f/g TE Z fps_t::divmod(fps f, cf g) -> pair { assert(g.back() != 0); int N = len(f), M = len(g); if (N < M) return {{}, f}; fps a = f, b = g; reverse(a); reverse(b); int d = N - M + 1; sh(a, d); sh(b, d); a = div(a, b); reverse(a); b = conv(a, g); FOR(i, N) f[i] -= b[i]; while (not f.empty() and f.back().val() == 0) pop(f); return {a, f}; } #line 2 "YRS/poly/c/ntt_db.hpp" #line 2 "YRS/poly/c/trans_ntt.hpp" #line 4 "YRS/poly/c/trans_ntt.hpp" TE Z fps_t::trans_ntt(vc &a, bool in) -> void { assert(T::can_ntt()); const uint m = T::get_mod(); static T w[30], iw[30], r[30], ir[30], b[30], ib[30]; static bool ok = 0; if (ok == 0) ok = 1, ntr(w, iw, r, ir, b, ib); #define f(k) a[i + of + k * p] #define g(k) ull(f(k).val()) #define tp topbit(~s & -~s) int N = len(a), n = topbit(N); if (not in) { int sz = n; while (sz) { if (sz == 1) { int p = 1 << (n - sz); T c = 1; FOR(s, 1 << (sz - 1)) { int of = s << (n - sz + 1); FOR(i, p) { T l = f(0), w = f(1) * c; f(0) = l + w, f(1) = l - w; } c *= r[tp]; } --sz; } else { int p = 1 << (n - sz); T c = 1, in = w[2]; FOR(s, 1 << (sz - 2)) { T rr = c * c, R = rr * c; int of = s << (n - sz + 2); FOR(i, p) { ull x = g(0), y = g(1), e = g(2), r = g(3), t = (m + e - r) * in.val() % m; f(0) = x + y + e + r; f(1) = (x + m - y + t) * c.val(); f(2) = (x + y + m + m - e - r) * rr.val(); f(3) = (x + m + m - y - t) * R.val(); } c *= b[tp]; } sz -= 2; } } } else { T c = T(N).inv(); FOR(i, N) a[i] *= c; int sz = 0; while (sz < n) { T c = 1; if (sz == n - 1) { int p = 1 << (n - sz - 1); FOR(s, 1 << sz) { int of = s << (n - sz); FOR(i, p) { T l = f(0), w = f(1) * c; f(0) = l + w, f(1) = l - w; } c *= ir[tp]; } ++sz; } else { int p = 1 << (n - sz - 2); T in = iw[2]; FOR(s, 1 << sz) { T rr = c * c, R = rr * c; int of = s << (n - sz); FOR(i, p) { ull x = g(0), y = g(1) * c.val(), e = g(2) * rr.val(), r = g(3) * R.val(), t = (y + M - r) % m * in.val(); f(0) = x + y + e + r; f(1) = x + e + (2 * M - y - r); f(2) = x + M - e + t; f(3) = x + M + M - e - t; } c *= ib[tp]; } sz += 2; } } } } #undef f #undef g #undef tp #line 5 "YRS/poly/c/ntt_db.hpp" TE Z fps_t::ntt_db(fps &a, bool tr) -> void { static array rt; static bool ok = 0; if (not ok) { ok = 1; rt[t] = r; FOR_R(i, t) rt[i] = rt[i + 1] * rt[i + 1]; } if (not tr) { int N = len(a); Z b = a; ntt(b, 1); T s = 1, c = rt[topbit(N << 1)]; FOR(i, N) b[i] *= s, s *= c; ntt(b, 0); copy(all(b), back_inserter(a)); } else { int N = len(a) >> 1; fps t{a.begin(), a.begin() + N}; a = {a.begin() + N, a.end()}; trans_ntt(a, 0); T s = 1, c = rt[topbit(N << 1)]; FOR(i, N) a[i] *= s, s *= c; trans_ntt(a, 1); FOR(i, N) a[i] += t[i]; } } #line 5 "YRS/poly/coef_of_rationals.hpp" // https://judge.yosupo.jp/problem/kth_term_of_linearly_recurrent_sequence // https://yukicoder.me/problems/no/213 TE Z fps_t::coef_of_rationals_ntt(fps p, fps q, ll k) -> T { assert(len(p) + 1 == len(q) and q[0] == T(1)); if (p.empty()) return 0; int N = 1; while (N < len(q)) N <<= 1; fps w(N); vc b(N); int n = topbit(N); FOR(i, N) b[i] = (b[i >> 1] >> 1) + ((i & 1) << (n - 1)); const int t = T::ntt_info().fi; const T r = T::ntt_info().se; T s = r.inv().pow((1 << t) / (N << 1)), c = inv(2); for (int i : b) w[i] = c, c *= s; sh(p, N << 1); sh(q, N << 1); ntt(p, 0); ntt(q, 0); while (k >= N) { if (not(k & 1)) { FOR(i, N) { p[i] = (p[i << 1] * q[i << 1 | 1] + p[i << 1 | 1] * q[i << 1]) * inv(2); } } else { FOR(i, N) { p[i] = (p[i << 1] * q[i << 1 | 1] - p[i << 1 | 1] * q[i << 1]) * w[i]; } } FOR(i, N) q[i] = q[i << 1] * q[i << 1 | 1]; sh(p, N); sh(q, N); k >>= 1; if (k < N) break; ntt_db(p), ntt_db(q); } ntt(p, 1), ntt(q, 1); q = inv(q); T res = 0; FOR(i, k + 1) res += p[i] * q[k - i]; return res; } TE Z fps_t::coef_of_rationals_mtt(fps p, fps q, ll k) -> T { assert(len(p) + 1 == len(q) and q[0] == T(1)); if (p.empty()) return 0; while (k >= len(p)) { vc a(q); int n = len(a); FOR(i, n) if (i & 1) a[i] = -a[i]; p = conv(p, a); q = conv(q, a); FOR(i, n) q[i] = q[i << 1]; FOR(i, n - 1) p[i] = p[i << 1 | (k & 1)]; sh(p, n - 1); sh(q, n); k >>= 1; } return div(p, q)[k]; } // [x^k]P/Q 求 ai=sum ci ai-j 则是 p / {1, -c1, -c2} TE Z fps_t::coef_of_rationals(fps p, fps q, ll k) -> T { if (p.empty()) return {}; assert(len(q) > 0 and q[0] != T(0)); while (q.back().val() == 0) pop(q); T c = q[0].inv(), s = 0; for (T &x : p) x *= c; for (T &x : q) x *= c; if (len(p) >= len(q)) { Z [f, g] = divmod(p, q); s = (k < len(f) ? f[k] : T(0)); p = g; } sh(p, len(q) - 1); if (T::can_ntt()) return s + coef_of_rationals_ntt(p, q, k); return s + coef_of_rationals_mtt(p, q, k); } TE Z fps_t::coef_of_rationals(fps p, fps q, ll l, ll r) -> fps { int m = r - l; if (m <= 0 or p.empty()) return {}; assert(len(q) > 0 and q[0].val() != 0); while (q.back().val() == 0) pop(q); T c = q[0].inv(); for (T &x : p) x *= c; for (T &x : q) x *= c; fps S, rem = p, res(m); if (len(p) >= len(q)) { Z [f, g] = divmod(p, q); S = f, p = g; } if (not S.empty()) { ll l0 = max(l, 0), r0 = min(r, len(S)); for (ll i = l0; i < r0; ++i) res[i - l] += S[i]; } int deg = len(q) - 1, bs = max(64, 2 * deg); sh(p, deg); Z f = [&](Z &&f, fps P, fps Q, ll l, ll r) -> fps { if (r <= l) return {}; if (P.empty()) return fps((int)(r - l), T(0)); while ((int)Q.size() > 1 && Q.back().val() == 0) pop(Q); if (r <= bs) { fps F((int)r); int up = min((int)P.size(), (int)r); for (int i = 0; i < up; ++i) F[i] = P[i]; fps A = div(F, Q); fps rs((int)(r - l)); for (int i = 0; i < (int)(r - l); ++i) rs[i] = A[(int)l + i]; return rs; } fps Qn = Q; for (int i = 1; i < (int)Qn.size(); i += 2) Qn[i] = -Qn[i]; fps C = conv(P, Qn); fps D = conv(Q, Qn); int n = (int)Q.size(); // n = deg(Q)+1 fps Qe(n, T(0)); for (int i = 0; i < n; ++i) { int idx = i << 1; if (idx < (int)D.size()) Qe[i] = D[idx]; } while ((int)Qe.size() > 1 && Qe.back().val() == 0) pop(Qe); int m = (int)Qe.size() - 1; // = deg(Qe) fps Pe(m, T(0)), Po(m, T(0)); for (int i = 0; i < m; ++i) { int ei = i << 1; int oi = ei | 1; if (ei < (int)C.size()) Pe[i] = C[ei]; if (oi < (int)C.size()) Po[i] = C[oi]; } ll le = (l + 1) / 2, re = (r + 1) / 2; ll lo = l / 2, ro = r / 2; fps even = f(f, Pe, Qe, le, re); fps odd = f(f, Po, Qe, lo, ro); fps rs((int)(r - l)); for (ll k = l; k < r; ++k) { if ((k & 1) == 0) { ll n = k >> 1; rs[k - l] = even[n - le]; } else { ll n = k >> 1; rs[k - l] = odd[n - lo]; } } return rs; }; ll l0 = max(0, l), r0 = max(0, r); if (r0 > l0) { fps seg = f(f, p, q, l0, r0); // seg size = r0-l0 for (int i = 0; i < (int)seg.size(); ++i) res[(l0 - l) + i] += seg[i]; } return res; } #line 6 "No_213_\u7d20\u6570\u30b5\u30a4\u30b3\u30ed\u3068\u5408\u6210\u6570\u30b5\u30a4\u30b3\u30ed_3_Easy.cpp" using mint = M11; using fps = vc; fps_t X; fps gen(const vc &a, int c) { fps go(100); int N = len(a); Z f = [&](Z &f, int n, int s, int ls) -> void { if (n == N) { go[s] += ls == 0; return; } FOR(i, ls + 1) f(f, n + 1, s + i * a[n], ls - i); }; f(f, 0, 0, c); while(not go.empty() and go.back().val() == 0) pop(go); return go; } void Yorisou() { LL(N, P, C); vc a{2, 3, 5, 7, 11, 13}, b{4, 6, 8, 9, 10, 12}; fps f = X.conv(gen(a, P), gen(b, C)); int sz = len(f); fps g = f, ls(sz << 1); for (mint &x : f) x = -x; f[0] += 1; int d = min(N, sz); Z coef = X.coef_of_rationals(fps{1}, f, N - d, N); copy(all(coef), begin(ls) + sz - d); // FOR(i, 1, min(N, sz) + 1) { // assert(ls[sz - i] == X.coef_of_rationals(fps{1}, f, N - i)); // ls[sz - i] = X.coef_of_rationals(fps{1}, f, N - i); // } ls = X.conv(ls, g); mint s; FOR(i, sz, sz << 1) s += ls[i]; print(s); } constexpr int tests = 0, fl = 0, DB = 10; #line 1 "YRS/aa/main.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int T = 1; if (fl) cerr.tie(0); if (tests and not fl) IN(T); for (int i = 0; i < T or fl; ++i) { Yorisou(); if (fl and i % DB == 0) cerr << "Case: " << i << '\n'; } return 0; } #line 46 "No_213_\u7d20\u6570\u30b5\u30a4\u30b3\u30ed\u3068\u5408\u6210\u6570\u30b5\u30a4\u30b3\u30ed_3_Easy.cpp"