#include #include #include #include using namespace std; using i64 = long long; constexpr i64 O = 3, M = (5LL << 37) * 211 + 1, // 48 ビット R2 = 65087448474821LL; // (2**63)**2 % M inline __uint128_t MR(__uint128_t t) { __uint128_t y = ((t * (M-2) & 0x7fffffffffffffffLL) * M + t) >> 63; if(y >= M) { y -= M; } return y; } inline i64 mod_mul(const __uint128_t &x, const __uint128_t &y, const i64 &m) { return i64(MR(MR(MR(x * R2) * MR(y * R2)))); } map, i64> cache; inline i64 mod_pow(i64 a, i64 n, const i64 &m) { auto key = make_tuple(a, n, m); if(cache.count(key)) { return cache[key]; } i64 res = 1; for(; n; n>>=1) { if(n & 1) { res = mod_mul(res, a, m); } a = mod_mul(a, a, m); } return cache[key] = res; } void myfmt(vector &a, bool inv) { int n = int(a.size()); if(n == 1) { return; } int m = n / 2; vector a0(m), a1(m); for(int i=0, j=0; i &a) { myfmt(a, false); } void ifmt(vector &a) { myfmt(a, true); int n = int(a.size()); i64 inv = mod_pow(n, M-2, M); for(int i=0; i convol(vector a, vector b) { int n = 1; while(n < a.size() + b.size()) { n <<= 1; } a.resize(n); b.resize(n); fmt(a); fmt(b); vector c(n); for(int i=0; i cnt(N); for(int i=0; i c = convol(cnt, cnt); i64 res = 0; if(x < c.size()) { res = c[x]; } printf("%lld\n", res); return 0; }