QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290052 | #7609. Colonization | ecnerwala# | AC ✓ | 10ms | 3948kb | C++23 | 30.8kb | 2023-12-24 12:05:41 | 2023-12-24 12:05:43 |
Judging History
answer
#include <bits/stdc++.h>
template <typename T> T mod_inv_in_range(T a, T m) {
// assert(0 <= a && a < m);
T x = a, y = m;
// coeff of a in x and y
T vx = 1, vy = 0;
while (x) {
T k = y / x;
y %= x;
vy -= k * vx;
std::swap(x, y);
std::swap(vx, vy);
}
assert(y == 1);
return vy < 0 ? m + vy : vy;
}
template <typename T> struct extended_gcd_result {
T gcd;
T coeff_a, coeff_b;
};
template <typename T> extended_gcd_result<T> extended_gcd(T a, T b) {
T x = a, y = b;
// coeff of a and b in x and y
T ax = 1, ay = 0;
T bx = 0, by = 1;
while (x) {
T k = y / x;
y %= x;
ay -= k * ax;
by -= k * bx;
std::swap(x, y);
std::swap(ax, ay);
std::swap(bx, by);
}
return {y, ay, by};
}
template <typename T> T mod_inv(T a, T m) {
a %= m;
a = a < 0 ? a + m : a;
return mod_inv_in_range(a, m);
}
template <int MOD_> struct modnum {
static constexpr int MOD = MOD_;
static_assert(MOD_ > 0, "MOD must be positive");
private:
int v;
public:
modnum() : v(0) {}
modnum(int64_t v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
explicit operator int() const { return v; }
friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
friend std::istream& operator >> (std::istream& in, modnum& n) { int64_t v_; in >> v_; n = modnum(v_); return in; }
friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
modnum inv() const {
modnum res;
res.v = mod_inv_in_range(v, MOD);
return res;
}
friend modnum inv(const modnum& m) { return m.inv(); }
modnum neg() const {
modnum res;
res.v = v ? MOD-v : 0;
return res;
}
friend modnum neg(const modnum& m) { return m.neg(); }
modnum operator- () const {
return neg();
}
modnum operator+ () const {
return modnum(*this);
}
modnum& operator ++ () {
v ++;
if (v == MOD) v = 0;
return *this;
}
modnum& operator -- () {
if (v == 0) v = MOD;
v --;
return *this;
}
modnum& operator += (const modnum& o) {
v -= MOD-o.v;
v = (v < 0) ? v + MOD : v;
return *this;
}
modnum& operator -= (const modnum& o) {
v -= o.v;
v = (v < 0) ? v + MOD : v;
return *this;
}
modnum& operator *= (const modnum& o) {
v = int(int64_t(v) * int64_t(o.v) % MOD);
return *this;
}
modnum& operator /= (const modnum& o) {
return *this *= o.inv();
}
friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
template <typename T> T pow(T a, long long b) {
assert(b >= 0);
T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}
template <typename U, typename V> struct pairnum {
U u;
V v;
pairnum() : u(0), v(0) {}
pairnum(long long val) : u(val), v(val) {}
pairnum(const U& u_, const V& v_) : u(u_), v(v_) {}
friend std::ostream& operator << (std::ostream& out, const pairnum& n) { return out << '(' << n.u << ',' << ' ' << n.v << ')'; }
friend std::istream& operator >> (std::istream& in, pairnum& n) { long long val; in >> val; n = pairnum(val); return in; }
friend bool operator == (const pairnum& a, const pairnum& b) { return a.u == b.u && a.v == b.v; }
friend bool operator != (const pairnum& a, const pairnum& b) { return a.u != b.u || a.v != b.v; }
pairnum inv() const {
return pairnum(u.inv(), v.inv());
}
pairnum neg() const {
return pairnum(u.neg(), v.neg());
}
pairnum operator- () const {
return pairnum(-u, -v);
}
pairnum operator+ () const {
return pairnum(+u, +v);
}
pairnum& operator ++ () {
++u, ++v;
return *this;
}
pairnum& operator -- () {
--u, --v;
return *this;
}
pairnum& operator += (const pairnum& o) {
u += o.u;
v += o.v;
return *this;
}
pairnum& operator -= (const pairnum& o) {
u -= o.u;
v -= o.v;
return *this;
}
pairnum& operator *= (const pairnum& o) {
u *= o.u;
v *= o.v;
return *this;
}
pairnum& operator /= (const pairnum& o) {
u /= o.u;
v /= o.v;
return *this;
}
friend pairnum operator ++ (pairnum& a, int) { pairnum r = a; ++a; return r; }
friend pairnum operator -- (pairnum& a, int) { pairnum r = a; --a; return r; }
friend pairnum operator + (const pairnum& a, const pairnum& b) { return pairnum(a) += b; }
friend pairnum operator - (const pairnum& a, const pairnum& b) { return pairnum(a) -= b; }
friend pairnum operator * (const pairnum& a, const pairnum& b) { return pairnum(a) *= b; }
friend pairnum operator / (const pairnum& a, const pairnum& b) { return pairnum(a) /= b; }
};
template <typename tag> struct dynamic_modnum {
private:
#if __cpp_inline_variables >= 201606
// C++17 and up
inline static int MOD_ = 0;
inline static uint64_t BARRETT_M = 0;
#else
// NB: these must be initialized out of the class by hand:
// static int dynamic_modnum<tag>::MOD = 0;
// static int dynamic_modnum<tag>::BARRETT_M = 0;
static int MOD_;
static uint64_t BARRETT_M;
#endif
public:
// Make only the const-reference public, to force the use of set_mod
static constexpr int const& MOD = MOD_;
// Barret reduction taken from KACTL:
/**
* Author: Simon Lindholm
* Date: 2020-05-30
* License: CC0
* Source: https://en.wikipedia.org/wiki/Barrett_reduction
* Description: Compute $a \% b$ about 5 times faster than usual, where $b$ is constant but not known at compile time.
* Returns a value congruent to $a \pmod b$ in the range $[0, 2b)$.
* Status: proven correct, stress-tested
* Measured as having 4 times lower latency, and 8 times higher throughput, see stress-test.
* Details:
* More precisely, it can be proven that the result equals 0 only if $a = 0$,
* and otherwise lies in $[1, (1 + a/2^64) * b)$.
*/
static void set_mod(int mod) {
assert(mod > 0);
MOD_ = mod;
BARRETT_M = (uint64_t(-1) / MOD);
}
static uint32_t barrett_reduce_partial(uint64_t a) {
return uint32_t(a - uint64_t((__uint128_t(BARRETT_M) * a) >> 64) * MOD);
}
static int barrett_reduce(uint64_t a) {
int32_t res = int32_t(barrett_reduce_partial(a) - MOD);
return (res < 0) ? res + MOD : res;
}
struct mod_reader {
friend std::istream& operator >> (std::istream& i, mod_reader) {
int mod; i >> mod;
dynamic_modnum::set_mod(mod);
return i;
}
};
static mod_reader MOD_READER() {
return mod_reader();
}
private:
int v;
public:
dynamic_modnum() : v(0) {}
dynamic_modnum(int64_t v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
explicit operator int() const { return v; }
friend std::ostream& operator << (std::ostream& out, const dynamic_modnum& n) { return out << int(n); }
friend std::istream& operator >> (std::istream& in, dynamic_modnum& n) { int64_t v_; in >> v_; n = dynamic_modnum(v_); return in; }
friend bool operator == (const dynamic_modnum& a, const dynamic_modnum& b) { return a.v == b.v; }
friend bool operator != (const dynamic_modnum& a, const dynamic_modnum& b) { return a.v != b.v; }
dynamic_modnum inv() const {
dynamic_modnum res;
res.v = mod_inv_in_range(v, MOD);
return res;
}
friend dynamic_modnum inv(const dynamic_modnum& m) { return m.inv(); }
dynamic_modnum neg() const {
dynamic_modnum res;
res.v = v ? MOD-v : 0;
return res;
}
friend dynamic_modnum neg(const dynamic_modnum& m) { return m.neg(); }
dynamic_modnum operator- () const {
return neg();
}
dynamic_modnum operator+ () const {
return dynamic_modnum(*this);
}
dynamic_modnum& operator ++ () {
v ++;
if (v == MOD) v = 0;
return *this;
}
dynamic_modnum& operator -- () {
if (v == 0) v = MOD;
v --;
return *this;
}
dynamic_modnum& operator += (const dynamic_modnum& o) {
v -= MOD-o.v;
v = (v < 0) ? v + MOD : v;
return *this;
}
dynamic_modnum& operator -= (const dynamic_modnum& o) {
v -= o.v;
v = (v < 0) ? v + MOD : v;
return *this;
}
dynamic_modnum& operator *= (const dynamic_modnum& o) {
v = barrett_reduce(int64_t(v) * int64_t(o.v));
return *this;
}
dynamic_modnum& operator /= (const dynamic_modnum& o) {
return *this *= o.inv();
}
friend dynamic_modnum operator ++ (dynamic_modnum& a, int) { dynamic_modnum r = a; ++a; return r; }
friend dynamic_modnum operator -- (dynamic_modnum& a, int) { dynamic_modnum r = a; --a; return r; }
friend dynamic_modnum operator + (const dynamic_modnum& a, const dynamic_modnum& b) { return dynamic_modnum(a) += b; }
friend dynamic_modnum operator - (const dynamic_modnum& a, const dynamic_modnum& b) { return dynamic_modnum(a) -= b; }
friend dynamic_modnum operator * (const dynamic_modnum& a, const dynamic_modnum& b) { return dynamic_modnum(a) *= b; }
friend dynamic_modnum operator / (const dynamic_modnum& a, const dynamic_modnum& b) { return dynamic_modnum(a) /= b; }
};
/**
* Author: Andrew He
* Source: http://neerc.ifmo.ru/trains/toulouse/2017/fft2.pdf
* Papers about accuracy: http://www.daemonology.net/papers/fft.pdf, http://www.cs.berkeley.edu/~fateman/papers/fftvsothers.pdf
* For integers rounding works if $(|a| + |b|)\max(a, b) < \mathtt{\sim} 10^9$, or in theory maybe $10^6$.
*/
namespace ecnerwala {
namespace fft {
using std::swap;
using std::vector;
using std::min;
using std::max;
template<class T> int sz(T&& arg) { using std::size; return int(size(std::forward<T>(arg))); }
inline int nextPow2(int s) { return 1 << (s > 1 ? 32 - __builtin_clz(s-1) : 0); }
// Complex
template <typename dbl> struct cplx { /// start-hash
dbl x, y;
cplx(dbl x_ = 0, dbl y_ = 0) : x(x_), y(y_) { }
friend cplx operator+(cplx a, cplx b) { return cplx(a.x + b.x, a.y + b.y); }
friend cplx operator-(cplx a, cplx b) { return cplx(a.x - b.x, a.y - b.y); }
friend cplx operator*(cplx a, cplx b) { return cplx(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
friend cplx conj(cplx a) { return cplx(a.x, -a.y); }
friend cplx inv(cplx a) { dbl n = (a.x*a.x+a.y*a.y); return cplx(a.x/n,-a.y/n); }
};
// getRoot implementations
template <typename num> struct getRoot {
static num f(int k) = delete;
};
template <typename dbl> struct getRoot<cplx<dbl>> {
static cplx<dbl> f(int k) {
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
dbl a=2*M_PI/k;
return cplx<dbl>(cos(a),sin(a));
}
};
template <int MOD> struct primitive_root {
static const int value;
};
template <> struct primitive_root<998244353> {
static const int value = 3;
};
template <int MOD> struct getRoot<modnum<MOD>> {
static modnum<MOD> f(int k) {
assert((MOD-1)%k == 0);
return pow(modnum<MOD>(primitive_root<MOD>::value), (MOD-1)/k);
}
};
template <typename num> class fft {
static vector<int> rev;
static vector<num> rt;
public:
static void init(int n);
template <typename Iterator> static void go(Iterator begin, int n);
static vector<num> scratch_a;
static vector<num> scratch_b;
};
template <typename num> vector<int> fft<num>::rev;
template <typename num> vector<num> fft<num>::rt;
template <typename num> vector<num> fft<num>::scratch_a;
template <typename num> vector<num> fft<num>::scratch_b;
template <typename num> void fft<num>::init(int n) {
if (n <= sz(rt)) return;
rev.resize(n);
for (int i = 0; i < n; i++) {
rev[i] = (rev[i>>1] | ((i&1)*n)) >> 1;
}
rt.reserve(n);
while (sz(rt) < 2 && sz(rt) < n) rt.push_back(num(1));
for (int k = sz(rt); k < n; k *= 2) {
rt.resize(2*k);
num z = getRoot<num>::f(2*k);
for (int i = k/2; i < k; i++) {
rt[2*i] = rt[i], rt[2*i+1] = rt[i]*z;
}
}
}
template <typename num> template <typename Iterator> void fft<num>::go(Iterator begin, int n) {
init(n);
int s = __builtin_ctz(sz(rev)/n);
for (int i = 0; i < n; i++) {
if (i < (rev[i]>>s)) {
swap(*(begin+i), *(begin+(rev[i]>>s)));
}
}
for (int k = 1; k < n; k *= 2) {
for (int i = 0; i < n; i += 2 * k) {
Iterator it1 = begin + i, it2 = it1 + k;
for (int j = 0; j < k; j++, ++it1, ++it2) {
num t = rt[j+k] * *it2;
*it2 = *it1 - t;
*it1 = *it1 + t;
}
}
}
}
template <typename num> struct fft_multiplier {
template <typename IterA, typename IterB, typename IterOut>
static void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {
vector<num>& fa = fft<num>::scratch_a;
vector<num>& fb = fft<num>::scratch_b;
if (sza == 0 || szb == 0) return;
int s = sza + szb - 1;
int n = nextPow2(s);
if (sz(fa) < n) fa.resize(n);
if (sz(fb) < n) fb.resize(n);
fft<num>::init(n);
bool did_cut = false;
if (sza > 1 && szb > 1 && n == 2 * (s - 1)) {
// we have exactly 1 wraparound, so let's just handle it explicitly to save a factor of 2
// only do it if sza < s and szb < s so we don't have to wrap the inputs
did_cut = true;
n /= 2;
}
copy(ia, ia+sza, fa.begin());
fill(fa.begin()+sza, fa.begin()+n, num(0));
copy(ib, ib+szb, fb.begin());
fill(fb.begin()+szb, fb.begin()+n, num(0));
// used if did_cut
num v_init; if (did_cut) { v_init = fa[0] * fb[0]; }
fft<num>::go(fa.begin(), n);
fft<num>::go(fb.begin(), n);
num d = inv(num(n));
for (int i = 0; i < n; i++) fa[i] = fa[i] * fb[i] * d;
reverse(fa.begin()+1, fa.begin()+n);
fft<num>::go(fa.begin(), n);
if (did_cut) {
fa[s-1] = std::exchange(fa[0], v_init) - v_init;
}
copy(fa.begin(), fa.begin()+s, io);
}
template <typename IterA, typename IterOut>
static void square(IterA ia, int sza, IterOut io) {
multiply<IterA, IterA, IterOut>(ia, sza, ia, sza, io);
}
};
template <typename num>
struct fft_inverser {
template <typename IterA, typename IterOut>
static void inverse(IterA ia, int sza, IterOut io) {
vector<num>& fa = fft<num>::scratch_a;
vector<num>& fb = fft<num>::scratch_b;
if (sza == 0) return;
int s = nextPow2(sza) * 2;
fft<num>::init(s);
if (sz(fa) < s) fa.resize(s);
if (sz(fb) < s) fb.resize(s);
fb[0] = inv(*ia);
for (int n = 1; n < sza; ) {
fill(fb.begin() + n, fb.begin() + 4 * n, num(0));
n *= 2;
copy(ia, ia+min(n,sza), fa.begin());
fill(fa.begin()+min(n,sza), fa.begin()+2*n, 0);
fft<num>::go(fb.begin(), 2*n);
fft<num>::go(fa.begin(), 2*n);
num d = inv(num(2*n));
for (int i = 0; i < 2*n; i++) fb[i] = fb[i] * (2 - fa[i] * fb[i]) * d;
reverse(fb.begin()+1, fb.begin()+2*n);
fft<num>::go(fb.begin(), 2*n);
}
copy(fb.begin(), fb.begin()+sza, io);
}
};
template <typename dbl>
struct fft_double_multiplier {
template <typename IterA, typename IterB, typename IterOut>
static void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {
vector<cplx<dbl>>& fa = fft<cplx<dbl>>::scratch_a;
vector<cplx<dbl>>& fb = fft<cplx<dbl>>::scratch_b;
if (sza == 0 || szb == 0) return;
int s = sza + szb - 1;
int n = nextPow2(s);
fft<cplx<dbl>>::init(n);
if (sz(fa) < n) fa.resize(n);
if (sz(fb) < n) fb.resize(n);
fill(fa.begin(), fa.begin() + n, 0);
{ auto it = ia; for (int i = 0; i < sza; ++i, ++it) fa[i].x = *it; }
{ auto it = ib; for (int i = 0; i < szb; ++i, ++it) fa[i].y = *it; }
fft<cplx<dbl>>::go(fa.begin(), n);
for (auto& x : fa) x = x * x;
for (int i = 0; i < n; ++i) fb[i] = fa[(n-i)&(n-1)] - conj(fa[i]);
fft<cplx<dbl>>::go(fb.begin(), n);
{ auto it = io; for (int i = 0; i < s; ++i, ++it) *it = fb[i].y / (4*n); }
}
template <typename IterA, typename IterOut>
static void square(IterA ia, int sza, IterOut io) {
multiply<IterA, IterA, IterOut>(ia, sza, ia, sza, io);
}
};
template <typename mnum>
struct fft_mod_multiplier {
template <typename IterA, typename IterB, typename IterOut>
static void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {
using cnum = cplx<double>;
vector<cnum>& fa = fft<cnum>::scratch_a;
vector<cnum>& fb = fft<cnum>::scratch_b;
if (sza == 0 || szb == 0) return;
int s = sza + szb - 1;
int n = nextPow2(s);
fft<cnum>::init(n);
if (sz(fa) < n) fa.resize(n);
if (sz(fb) < n) fb.resize(n);
{ auto it = ia; for (int i = 0; i < sza; ++i, ++it) fa[i] = cnum(int(*it) & ((1<<15)-1), int(*it) >> 15); }
fill(fa.begin()+sza, fa.begin() + n, 0);
{ auto it = ib; for (int i = 0; i < szb; ++i, ++it) fb[i] = cnum(int(*it) & ((1<<15)-1), int(*it) >> 15); }
fill(fb.begin()+szb, fb.begin() + n, 0);
fft<cnum>::go(fa.begin(), n);
fft<cnum>::go(fb.begin(), n);
double r0 = 0.5 / n; // 1/2n
for (int i = 0; i <= n/2; i++) {
int j = (n-i)&(n-1);
cnum g0 = (fb[i] + conj(fb[j])) * r0;
cnum g1 = (fb[i] - conj(fb[j])) * r0;
swap(g1.x, g1.y); g1.y *= -1;
if (j != i) {
swap(fa[j], fa[i]);
fb[j] = fa[j] * g1;
fa[j] = fa[j] * g0;
}
fb[i] = fa[i] * conj(g1);
fa[i] = fa[i] * conj(g0);
}
fft<cnum>::go(fa.begin(), n);
fft<cnum>::go(fb.begin(), n);
using ll = long long;
const ll m = mnum::MOD;
auto it = io;
for (int i = 0; i < s; ++i, ++it) {
*it = mnum((ll(fa[i].x+0.5)
+ (ll(fa[i].y+0.5) % m << 15)
+ (ll(fb[i].x+0.5) % m << 15)
+ (ll(fb[i].y+0.5) % m << 30)) % m);
}
}
template <typename IterA, typename IterOut>
static void square(IterA ia, int sza, IterOut io) {
multiply<IterA, IterA, IterOut>(ia, sza, ia, sza, io);
}
};
template <class multiplier, typename num>
struct multiply_inverser {
template <typename IterA, typename IterOut>
static void inverse(IterA ia, int sza, IterOut io) {
if (sza == 0) return;
int s = nextPow2(sza);
vector<num> b(s,num(0));
vector<num> tmp(2*s);
b[0] = inv(*ia);
for (int n = 1; n < sza; ) {
multiplier::square(b.begin(),n,tmp.begin());
int nn = min(sza,2*n);
multiplier::multiply(tmp.begin(),nn,ia,nn,tmp.begin());
for (int i = n; i < nn; i++) b[i] = -tmp[i];
n = nn;
}
copy(b.begin(), b.begin()+sza, io);
}
};
template <class multiplier, typename T> vector<T> multiply(const vector<T>& a, const vector<T>& b) {
if (sz(a) == 0 || sz(b) == 0) return {};
vector<T> r(sz(a) + sz(b) - 1);
multiplier::multiply(begin(a), sz(a), begin(b), sz(b), begin(r));
return r;
}
template <typename T> vector<T> fft_multiply(const vector<T>& a, const vector<T>& b) {
return multiply<fft_multiplier<T>, T>(a, b);
}
template <typename T> vector<T> fft_double_multiply(const vector<T>& a, const vector<T>& b) {
return multiply<fft_double_multiplier<T>, T>(a, b);
}
template <typename T> vector<T> fft_mod_multiply(const vector<T>& a, const vector<T>& b) {
return multiply<fft_mod_multiplier<T>, T>(a, b);
}
template <class multiplier, typename T> vector<T> square(const vector<T>& a) {
if (sz(a) == 0) return {};
vector<T> r(2 * sz(a) - 1);
multiplier::square(begin(a), sz(a), begin(r));
return r;
}
template <typename T> vector<T> fft_square(const vector<T>& a) {
return square<fft_multiplier<T>, T>(a);
}
template <typename T> vector<T> fft_double_square(const vector<T>& a) {
return square<fft_double_multiplier<T>, T>(a);
}
template <typename T> vector<T> fft_mod_square(const vector<T>& a) {
return square<fft_mod_multiplier<T>, T>(a);
}
template <class inverser, typename T> vector<T> inverse(const vector<T>& a) {
vector<T> r(sz(a));
inverser::inverse(begin(a), sz(a), begin(r));
return r;
}
template <typename T> vector<T> fft_inverse(const vector<T>& a) {
return inverse<fft_inverser<T>, T>(a);
}
template <typename T> vector<T> fft_double_inverse(const vector<T>& a) {
return inverse<multiply_inverser<fft_double_multiplier<T>, T>, T>(a);
}
template <typename T> vector<T> fft_mod_inverse(const vector<T>& a) {
return inverse<multiply_inverser<fft_mod_multiplier<T>, T>, T>(a);
}
/* namespace fft */ }
// Power series; these are assumed to be the min of the length
template <typename T, typename multiplier, typename inverser>
struct power_series : public std::vector<T> {
using std::vector<T>::vector;
int ssize() const {
return int(this->size());
}
int len() const {
return ssize();
}
int degree() const {
return len() - 1;
}
void extend(int sz) {
assert(sz >= ssize());
this->resize(sz);
}
void shrink(int sz) {
assert(sz <= ssize());
this->resize(sz);
}
// multiply by x^n
void shift(int n = 1) {
assert(n >= 0 && n <= ssize());
std::rotate(this->begin(), this->end()-n, this->end());
std::fill(this->begin(), this->begin()+n, T(0));
}
// divide by x^n and 0-pad
void unshift(int n = 1) {
assert(n >= 0 && n <= ssize());
std::fill(this->begin(), this->begin()+n, T(0));
std::rotate(this->begin(), this->begin()+n, this->end());
}
power_series& operator += (const power_series& o) {
assert(len() == o.len());
for (int i = 0; i < int(o.size()); i++) {
(*this)[i] += o[i];
}
return *this;
}
friend power_series operator + (const power_series& a, const power_series& b) {
power_series r(std::min(a.size(), b.size()));
for (int i = 0; i < r.len(); i++) {
r[i] = a[i] + b[i];
}
return r;
}
power_series& operator -= (const power_series& o) {
assert(len() == o.len());
for (int i = 0; i < int(o.size()); i++) {
(*this)[i] -= o[i];
}
return *this;
}
friend power_series operator - (const power_series& a, const power_series& b) {
power_series r(std::min(a.size(), b.size()));
for (int i = 0; i < r.len(); i++) {
r[i] = a[i] - b[i];
}
return r;
}
power_series& operator *= (const T& n) {
for (auto& v : *this) v *= n;
return *this;
}
friend power_series operator * (const power_series& a, const T& n) {
power_series r(a.size());
for (int i = 0; i < a.len(); i++) {
r[i] = a[i] * n;
}
return r;
}
friend power_series operator * (const T& n, const power_series& a) {
power_series r(a.size());
for (int i = 0; i < a.len(); i++) {
r[i] = n * a[i];
}
return r;
}
friend power_series operator * (const power_series& a, const power_series& b) {
if (sz(a) == 0 || sz(b) == 0) return {};
power_series r(std::max(0, sz(a) + sz(b) - 1));
multiplier::multiply(begin(a), sz(a), begin(b), sz(b), begin(r));
r.resize(std::min(a.size(), b.size()));
return r;
}
power_series& operator *= (const power_series& o) {
return *this = (*this) * o;
}
friend power_series square(const power_series& a) {
if (sz(a) == 0) return {};
power_series r(sz(a) * 2 - 1);
multiplier::square(begin(a), sz(a), begin(r));
r.resize(a.size());
return r;
}
friend power_series stretch(const power_series& a, int n) {
power_series r(a.size());
for (int i = 0; i*n < int(a.size()); i++) {
r[i*n] = a[i];
}
return r;
}
friend power_series inverse(power_series a) {
power_series r(sz(a));
inverser::inverse(begin(a), sz(a), begin(r));
return r;
}
friend power_series deriv_shift(power_series a) {
for (int i = 0; i < a.len(); i++) {
a[i] *= i;
}
return a;
}
friend power_series integ_shift(power_series a) {
assert(a[0] == 0);
T f = 1;
for (int i = 1; i < int(a.size()); i++) {
a[i] *= f;
f *= i;
}
f = inv(f);
for (int i = int(a.size()) - 1; i > 0; i--) {
a[i] *= f;
f *= i;
}
return a;
}
friend power_series deriv_shift_log(power_series a) {
auto r = deriv_shift(a);
return r * inverse(a);
}
friend power_series poly_log(power_series a) {
assert(a[0] == 1);
return integ_shift(deriv_shift_log(std::move(a)));
}
friend power_series poly_exp(power_series a) {
assert(a.size() >= 1);
assert(a[0] == 0);
power_series r(1, T(1));
while (r.size() < a.size()) {
int n_sz = std::min(int(r.size()) * 2, int(a.size()));
r.resize(n_sz);
power_series v(a.begin(), a.begin() + n_sz);
v -= poly_log(r);
v[0] += 1;
r *= v;
}
return r;
}
friend power_series poly_pow_monic(power_series a, int64_t k) {
if (a.empty()) return a;
assert(a.size() >= 1);
assert(a[0] == 1);
a = poly_log(a);
a *= k;
return poly_exp(a);
}
friend power_series poly_pow(power_series a, int64_t k) {
int st = 0;
while (st < a.len() && a[st] == 0) st++;
if (st == a.len()) return a;
power_series r(a.begin() + st, a.end());
T leading_coeff = r[0];
r *= inv(leading_coeff);
r = poly_pow_monic(r, k);
r *= pow(leading_coeff, k);
r.insert(r.begin(), size_t(st), T(0));
return r;
}
friend power_series to_newton_sums(const power_series& a, int deg) {
auto r = log_deriv_shift(a);
r[0] = deg;
for (int i = 1; i < int(r.size()); i++) r[i] = -r[i];
return r;
}
friend power_series from_newton_sums(power_series S, int deg) {
assert(S[0] == int(deg));
S[0] = 0;
for (int i = 1; i < int(S.size()); i++) S[i] = -S[i];
return poly_exp(integ_shift(std::move(S)));
}
// Calculates prod 1/(1-x^i)^{a[i]}
friend power_series euler_transform(const power_series& a) {
power_series r = deriv_shift(a);
std::vector<bool> is_prime(a.size(), true);
for (int p = 2; p < int(a.size()); p++) {
if (!is_prime[p]) continue;
for (int i = 1; i*p < int(a.size()); i++) {
r[i*p] += r[i];
is_prime[i*p] = false;
}
}
return poly_exp(integ_shift(r));
}
friend power_series inverse_euler_transform(const power_series& a) {
power_series r = deriv_shift(poly_log(a));
std::vector<bool> is_prime(a.size(), true);
for (int p = 2; p < int(a.size()); p++) {
if (!is_prime[p]) continue;
for (int i = (int(a.size())-1)/p; i >= 1; i--) {
r[i*p] -= r[i];
is_prime[i*p] = false;
}
}
return integ_shift(r);
}
};
template <typename num> using power_series_fft = power_series<num, fft::fft_multiplier<num>, fft::fft_inverser<num>>;
template <typename num, typename multiplier> using power_series_with_multiplier = power_series<num, multiplier, fft::multiply_inverser<multiplier, num>>;
template <typename num> using power_series_fft_mod = power_series_with_multiplier<num, fft::fft_mod_multiplier<num>>;
template <typename num> using power_series_fft_double = power_series_with_multiplier<num, fft::fft_double_multiplier<num>>;
// TODO: Use iterator traits to deduce value type?
template <typename base_iterator, typename value_type> struct add_into_iterator {
base_iterator base;
add_into_iterator() : base() {}
add_into_iterator(base_iterator b) : base(b) {}
add_into_iterator& operator * () { return *this; }
add_into_iterator& operator ++ () { base.operator ++ (); return *this; }
add_into_iterator& operator ++ (int) { auto temp = *this; operator ++ (); return temp; }
auto operator = (value_type v) { base.operator * () += v; }
};
// TODO: Use iterator traits to deduce value type?
template <typename base_iterator, typename value_type> struct add_double_into_iterator {
base_iterator base;
add_double_into_iterator() : base() {}
add_double_into_iterator(base_iterator b) : base(b) {}
add_double_into_iterator& operator * () { return *this; }
add_double_into_iterator& operator ++ () { base.operator ++ (); return *this; }
add_double_into_iterator& operator ++ (int) { auto temp = *this; operator ++ (); return temp; }
auto operator = (value_type v) { base.operator * () += 2 * v; }
};
template <typename num, typename multiplier> struct online_multiplier {
int N; int i;
std::vector<num> f, g;
std::vector<num> res;
// Computes the first 2N terms of the product
online_multiplier(int N_) : N(N_), i(0), f(N), g(N), res(2*N+1, num(0)) {}
num peek() {
return res[i];
}
void push(num v_f, num v_g) {
assert(i < N);
f[i] = v_f;
g[i] = v_g;
if (i == 0) {
res[i] += v_f * v_g;
} else {
res[i] += v_f * g[0];
res[i] += f[0] * v_g;
// TODO: We could do this second half more lazily, since it only affects res[i+1]...
for (int p = 1; (i & (p-1)) == (p-1); p <<= 1) {
int lo1 = p;
int lo2 = i + 1 - p;
multiplier::multiply(
// TODO: We can cache FFT([f,g].begin() + p, p)
f.begin() + lo1, p,
g.begin() + lo2, p,
add_into_iterator<decltype(res.begin()), num>(res.begin() + lo1 + lo2)
);
if (i == 2*p-1) break;
// TODO: Don't recompute if squaring
multiplier::multiply(
f.begin() + lo2, p,
g.begin() + lo1, p,
add_into_iterator<decltype(res.begin()), num>(res.begin() + lo1 + lo2)
);
}
}
i++;
}
num back() {
return res[i-1];
}
};
template <typename num, typename multiplier> struct online_squarer {
int N; int i;
std::vector<num> f;
std::vector<num> res;
// Computes the first 2N terms of the product
online_squarer(int N_) : N(N_), i(0), f(N), res(2*N+1, num(0)) {}
num peek() {
return res[i];
}
void push(num v_f) {
assert(i < N);
f[i] = v_f;
if (i == 0) {
res[i] += v_f * v_f;
} else {
res[i] += 2 * v_f * f[0];
// TODO: We could do this second half more lazily, since it only affects res[i+1]...
for (int p = 1; (i & (p-1)) == (p-1); p <<= 1) {
int lo1 = p;
int lo2 = i + 1 - p;
if (i == 2*p-1) {
multiplier::square(
// TODO: We can cache FFT([f,g].begin() + p, p)
f.begin() + lo1, p,
add_into_iterator<decltype(res.begin()), num>(res.begin() + lo1 + lo2)
);
break;
} else {
multiplier::multiply(
// TODO: Use cached FFT
f.begin() + lo1, p,
f.begin() + lo2, p,
add_double_into_iterator<decltype(res.begin()), num>(res.begin() + lo1 + lo2)
);
}
}
}
i++;
}
num back() {
return res[i-1];
}
};
/* namespace ecnerwala */ }
struct my_tag { };
using num = dynamic_modnum<my_tag>;
int main() {
using namespace std;
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int N; cin >> N >> num::MOD_READER();
assert(N >= 2);
using power_series = ecnerwala::power_series_fft_mod<num>;
power_series ONE(N+1);
ONE[0] = num(1);
std::vector<num> answers;
power_series ways_any(N+1, num(0));
ways_any[1] = 1;
power_series ways_at_most_one(N+1, num(0));
power_series ways_exactly_two(N+1, num(0));
for (int K = 1; (3 << (K-1)) - 2 <= N; K++) {
power_series ways_must = ways_any - ways_at_most_one;
power_series ways_chain = ways_must * inverse(ONE - ways_any);
power_series stretched_ways_chain = stretch(ways_chain, 2);
// We either have 3 K-1 children, or we're a path of length >= 2m each end of which is a must
power_series ans = (ways_must - ways_exactly_two)
+ (ways_must * ways_chain + stretched_ways_chain * (ONE + ways_any)) * inv(num(2));
answers.push_back(ans[N]);
ways_at_most_one = ways_any * (ONE + ways_chain);
ways_exactly_two = ways_any * (square(ways_chain) + stretched_ways_chain) * inv(num(2));
ways_any = ways_any * euler_transform(ways_chain);
}
answers.resize(N);
for (int i = 0; i < N; i++) {
cout << answers[i] << " \n"[i+1==N];
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3724kb
input:
3 100000007
output:
1 0 0
result:
ok 3 number(s): "1 0 0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
6 300000007
output:
1 5 0 0 0 0
result:
ok 6 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
10 1000000007
output:
1 104 1 0 0 0 0 0 0 0
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 739878731
output:
1 0
result:
ok 2 number(s): "1 0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
3 122646779
output:
1 0 0
result:
ok 3 number(s): "1 0 0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 457287433
output:
1 1 0 0
result:
ok 4 number(s): "1 1 0 0"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
5 1000000007
output:
1 2 0 0 0
result:
ok 5 number(s): "1 2 0 0 0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
6 1000000007
output:
1 5 0 0 0 0
result:
ok 6 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
7 763596907
output:
1 10 0 0 0 0 0
result:
ok 7 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
8 1000000007
output:
1 22 0 0 0 0 0 0
result:
ok 8 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
9 729507523
output:
1 46 0 0 0 0 0 0 0
result:
ok 9 numbers
Test #12:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
11 488473873
output:
1 230 4 0 0 0 0 0 0 0 0
result:
ok 11 numbers
Test #13:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
12 100000007
output:
1 531 19 0 0 0 0 0 0 0 0 0
result:
ok 12 numbers
Test #14:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
13 1000000007
output:
1 1223 77 0 0 0 0 0 0 0 0 0 0
result:
ok 13 numbers
Test #15:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
14 1000000007
output:
1 2871 287 0 0 0 0 0 0 0 0 0 0 0
result:
ok 14 numbers
Test #16:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
15 290707159
output:
1 6738 1002 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 15 numbers
Test #17:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
16 200746561
output:
1 15954 3365 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 16 numbers
Test #18:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
17 920695687
output:
1 37775 10853 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 17 numbers
Test #19:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
18 100000007
output:
1 89778 34088 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 18 numbers
Test #20:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
19 1000000007
output:
1 213380 104574 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 19 numbers
Test #21:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
20 1000000007
output:
1 507948 315116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 20 numbers
Test #22:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
21 1000000007
output:
1 1209183 935321 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 21 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
22 293085943
output:
1 2880381 2743373 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 22 numbers
Test #24:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
23 1000000007
output:
1 6861350 7966717 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 23 numbers
Test #25:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
24 1000000007
output:
1 16348886 22950963 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 24 numbers
Test #26:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
25 100000007
output:
1 38955353 65681223 313 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 25 numbers
Test #27:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
31 534112939
output:
1 192268405 73638402 6451797 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 31 numbers
Test #28:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
32 1000000007
output:
1 5929365 938116336 28363756 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 32 numbers
Test #29:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
33 100000007
output:
1 28626901 79818017 20396526 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 33 numbers
Test #30:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
45 449530979
output:
1 171137267 404676218 400336656 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 45 numbers
Test #31:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
46 1000000007
output:
1 199174750 533156646 230095585 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 46 numbers
Test #32:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
63 901518881
output:
1 463582236 485174050 287704421 146635752 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 63 numbers
Test #33:
score: 0
Accepted
time: 2ms
memory: 3740kb
input:
64 137267147
output:
1 35160421 46570987 16058722 84291291 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 64 numbers
Test #34:
score: 0
Accepted
time: 2ms
memory: 3796kb
input:
65 285342521
output:
1 274680000 185520281 272194478 194410283 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 65 numbers
Test #35:
score: 0
Accepted
time: 2ms
memory: 3720kb
input:
93 927588749
output:
1 739012354 414231470 524375705 491769836 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 93 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
94 1000000007
output:
1 174061321 12227912 673546067 414725694 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 94 numbers
Test #37:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
127 837565763
output:
1 446351899 736480797 801225275 81764442 837167518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 127 numbers
Test #38:
score: 0
Accepted
time: 3ms
memory: 3568kb
input:
128 100000007
output:
1 53744379 39517387 95806759 76712174 64599518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 128 numbers
Test #39:
score: 0
Accepted
time: 3ms
memory: 3628kb
input:
129 100000007
output:
1 54413572 77155852 35776158 8059026 50094475 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 129 numbers
Test #40:
score: 0
Accepted
time: 3ms
memory: 3772kb
input:
189 100000007
output:
1 20631572 98966220 97206167 20535001 98542068 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 189 numbers
Test #41:
score: 0
Accepted
time: 4ms
memory: 3712kb
input:
190 1000000007
output:
1 860182239 85061792 915947137 663567155 838976700 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 190 numbers
Test #42:
score: 0
Accepted
time: 5ms
memory: 3828kb
input:
251 100000007
output:
1 44059658 9262465 26500589 1719804 86005028 93059166 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 251 numbers
Test #43:
score: 0
Accepted
time: 4ms
memory: 3684kb
input:
252 438884497
output:
1 350004178 339722925 331392720 339369500 346888489 145616211 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 252 numbers
Test #44:
score: 0
Accepted
time: 4ms
memory: 3828kb
input:
253 603030559
output:
1 271460264 113828285 211485995 140494699 117148110 528164491 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 253 numbers
Test #45:
score: 0
Accepted
time: 4ms
memory: 3816kb
input:
254 348935141
output:
1 43492722 336540922 302203252 295334615 232628368 334090063 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 254 numbers
Test #46:
score: 0
Accepted
time: 4ms
memory: 3768kb
input:
255 1000000007
output:
1 91921129 240703773 860507313 874767125 217480414 312302154 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 255 numbers
Test #47:
score: 0
Accepted
time: 7ms
memory: 3780kb
input:
256 1000000007
output:
1 53171383 308195745 292391229 411819088 716198819 576070511 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 256 numbers
Test #48:
score: 0
Accepted
time: 8ms
memory: 3928kb
input:
257 100000007
output:
1 81139239 17341218 77559815 79820516 8464002 98148398 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 257 numbers
Test #49:
score: 0
Accepted
time: 7ms
memory: 3852kb
input:
258 442383839
output:
1 17124647 269217418 150135508 44573661 331788565 178732642 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 258 numbers
Test #50:
score: 0
Accepted
time: 7ms
memory: 3872kb
input:
259 1000000007
output:
1 110221852 366165150 234264934 260805622 864063783 707330112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 259 numbers
Test #51:
score: 0
Accepted
time: 5ms
memory: 3816kb
input:
260 712345379
output:
1 695448021 314265267 409389839 186491237 137959338 602047939 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 260 numbers
Test #52:
score: 0
Accepted
time: 8ms
memory: 3860kb
input:
261 905487833
output:
1 343672449 301480800 74963931 846427040 50121928 66712132 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 261 numbers
Test #53:
score: 0
Accepted
time: 8ms
memory: 3684kb
input:
379 785307437
output:
1 104449237 551856852 287086915 700424952 260302548 683038837 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 379 numbers
Test #54:
score: 0
Accepted
time: 8ms
memory: 3732kb
input:
380 1000000007
output:
1 898776986 792687672 458428823 424922724 540625189 703369531 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 380 numbers
Test #55:
score: 0
Accepted
time: 8ms
memory: 3820kb
input:
381 1000000007
output:
1 792757940 914747475 138265905 619378463 243945373 245237150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 381 numbers
Test #56:
score: 0
Accepted
time: 9ms
memory: 3944kb
input:
382 1000000007
output:
1 967586300 862777957 762030482 699420239 261107449 927966095 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 382 numbers
Test #57:
score: 0
Accepted
time: 9ms
memory: 3820kb
input:
383 215369873
output:
1 137773847 215004848 201659396 179799367 6430943 40328459 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 383 numbers
Test #58:
score: 0
Accepted
time: 9ms
memory: 3948kb
input:
384 1000000007
output:
1 507910674 458483513 431720627 483110084 435044603 540855576 369 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 384 numbers
Test #59:
score: 0
Accepted
time: 9ms
memory: 3756kb
input:
385 454793887
output:
1 248403036 291298368 251944296 296123869 371504911 24661638 8879 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 385 numbers
Test #60:
score: 0
Accepted
time: 9ms
memory: 3796kb
input:
386 1000000007
output:
1 265750215 79378345 232928900 483946141 205160466 429741317 202552 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 386 numbers
Test #61:
score: 0
Accepted
time: 9ms
memory: 3816kb
input:
387 227519269
output:
1 10763873 128932761 4923580 111935720 101016988 55107358 4366847 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 387 numbers
Test #62:
score: 0
Accepted
time: 6ms
memory: 3832kb
input:
388 1000000007
output:
1 958804227 524180264 304133528 240757407 115032333 782719263 89834392 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 388 numbers
Test #63:
score: 0
Accepted
time: 9ms
memory: 3824kb
input:
389 100000007
output:
1 1930815 57848302 3602158 77887435 14525348 1062339 70400721 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 389 numbers
Test #64:
score: 0
Accepted
time: 9ms
memory: 3640kb
input:
490 100000007
output:
1 96342386 17439556 23314154 89355902 37007860 13022516 15758638 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 490 numbers
Test #65:
score: 0
Accepted
time: 9ms
memory: 3840kb
input:
491 150073523
output:
1 9711255 122670986 90390709 18503883 27665285 140185636 116277727 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 491 numbers
Test #66:
score: 0
Accepted
time: 10ms
memory: 3752kb
input:
492 100000007
output:
1 53440278 34811222 65887674 39632523 80352836 51887989 53638950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 492 numbers
Test #67:
score: 0
Accepted
time: 9ms
memory: 3888kb
input:
493 1000000007
output:
1 744781325 335559402 899766846 495308909 483295651 260407300 970927089 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 493 numbers
Test #68:
score: 0
Accepted
time: 9ms
memory: 3904kb
input:
494 267940807
output:
1 173520076 91930068 196027436 182150385 254288786 233046355 184330491 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 494 numbers
Test #69:
score: 0
Accepted
time: 9ms
memory: 3900kb
input:
495 103825471
output:
1 103727223 64685514 91375652 39482044 46185280 83105809 50113222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 495 numbers
Test #70:
score: 0
Accepted
time: 9ms
memory: 3884kb
input:
496 849169157
output:
1 344999439 495436786 781457946 404504956 270903993 494266348 209361467 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 496 numbers
Test #71:
score: 0
Accepted
time: 9ms
memory: 3828kb
input:
497 662520673
output:
1 156500838 639965771 190377618 568425495 81997 303944968 210618835 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 497 numbers
Test #72:
score: 0
Accepted
time: 9ms
memory: 3892kb
input:
498 1000000007
output:
1 573703418 935865068 977863365 602392352 835769495 352753836 613593614 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 498 numbers
Test #73:
score: 0
Accepted
time: 9ms
memory: 3772kb
input:
499 197518697
output:
1 183648021 12587187 141992294 103512133 121413153 142956322 51677789 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 499 numbers
Test #74:
score: 0
Accepted
time: 9ms
memory: 3904kb
input:
500 351956881
output:
1 278454371 270002440 87590952 340114688 136937620 87109359 224401059 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500 numbers
Extra Test:
score: 0
Extra Test Passed