QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106708#6411. Classical FFT ProblemhitonanodeAC ✓6850ms39964kbC++1728.2kb2023-05-18 21:13:502023-05-18 21:13:52

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-18 21:13:52]
  • 评测
  • 测评结果:AC
  • 用时:6850ms
  • 内存:39964kb
  • [2023-05-18 21:13:50]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template <typename T, typename V>
void ndarray(vector<T>& vec, const V& val, int len) { vec.assign(len, val); }
template <typename T, typename V, typename... Args> void ndarray(vector<T>& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); }
template <typename T> bool chmax(T &m, const T q) { return m < q ? (m = q, true) : false; }
template <typename T> bool chmin(T &m, const T q) { return m > q ? (m = q, true) : false; }
const std::vector<std::pair<int, int>> grid_dxs{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); }
template <class T1, class T2> T1 floor_div(T1 num, T2 den) { return (num > 0 ? num / den : -((-num + den - 1) / den)); }
template <class T1, class T2> std::pair<T1, T2> operator+(const std::pair<T1, T2> &l, const std::pair<T1, T2> &r) { return std::make_pair(l.first + r.first, l.second + r.second); }
template <class T1, class T2> std::pair<T1, T2> operator-(const std::pair<T1, T2> &l, const std::pair<T1, T2> &r) { return std::make_pair(l.first - r.first, l.second - r.second); }
template <class T> std::vector<T> sort_unique(std::vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }
template <class T> int arglb(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::lower_bound(v.begin(), v.end(), x)); }
template <class T> int argub(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::upper_bound(v.begin(), v.end(), x)); }
template <class IStream, class T> IStream &operator>>(IStream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; }

template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec);
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr);
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const pair<T, U> &pa);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa);
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp);
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp);
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl);

template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
template <class... T> std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl) { os << '('; std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os << ')'; }
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa) { return os << '(' << pa.first << ',' << pa.second << ')'; }
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
#ifdef HITONANODE_LOCAL
const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m", NORMAL_CROSSED = "\033[0;9;37m", RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#define dbg(x) std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl
#define dbgif(cond, x) ((cond) ? std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl : std::cerr)
#else
#define dbg(x) ((void)0)
#define dbgif(cond, x) ((void)0)
#endif


template <int md> struct ModInt {
#if __cplusplus >= 201402L
#define MDCONST constexpr
#else
#define MDCONST
#endif
    using lint = long long;
    MDCONST static int mod() { return md; }
    static int get_primitive_root() {
        static int primitive_root = 0;
        if (!primitive_root) {
            primitive_root = [&]() {
                std::set<int> fac;
                int v = md - 1;
                for (lint i = 2; i * i <= v; i++)
                    while (v % i == 0) fac.insert(i), v /= i;
                if (v > 1) fac.insert(v);
                for (int g = 1; g < md; g++) {
                    bool ok = true;
                    for (auto i : fac)
                        if (ModInt(g).pow((md - 1) / i) == 1) {
                            ok = false;
                            break;
                        }
                    if (ok) return g;
                }
                return -1;
            }();
        }
        return primitive_root;
    }
    int val_;
    int val() const noexcept { return val_; }
    MDCONST ModInt() : val_(0) {}
    MDCONST ModInt &_setval(lint v) { return val_ = (v >= md ? v - md : v), *this; }
    MDCONST ModInt(lint v) { _setval(v % md + md); }
    MDCONST explicit operator bool() const { return val_ != 0; }
    MDCONST ModInt operator+(const ModInt &x) const {
        return ModInt()._setval((lint)val_ + x.val_);
    }
    MDCONST ModInt operator-(const ModInt &x) const {
        return ModInt()._setval((lint)val_ - x.val_ + md);
    }
    MDCONST ModInt operator*(const ModInt &x) const {
        return ModInt()._setval((lint)val_ * x.val_ % md);
    }
    MDCONST ModInt operator/(const ModInt &x) const {
        return ModInt()._setval((lint)val_ * x.inv().val() % md);
    }
    MDCONST ModInt operator-() const { return ModInt()._setval(md - val_); }
    MDCONST ModInt &operator+=(const ModInt &x) { return *this = *this + x; }
    MDCONST ModInt &operator-=(const ModInt &x) { return *this = *this - x; }
    MDCONST ModInt &operator*=(const ModInt &x) { return *this = *this * x; }
    MDCONST ModInt &operator/=(const ModInt &x) { return *this = *this / x; }
    friend MDCONST ModInt operator+(lint a, const ModInt &x) {
        return ModInt()._setval(a % md + x.val_);
    }
    friend MDCONST ModInt operator-(lint a, const ModInt &x) {
        return ModInt()._setval(a % md - x.val_ + md);
    }
    friend MDCONST ModInt operator*(lint a, const ModInt &x) {
        return ModInt()._setval(a % md * x.val_ % md);
    }
    friend MDCONST ModInt operator/(lint a, const ModInt &x) {
        return ModInt()._setval(a % md * x.inv().val() % md);
    }
    MDCONST bool operator==(const ModInt &x) const { return val_ == x.val_; }
    MDCONST bool operator!=(const ModInt &x) const { return val_ != x.val_; }
    MDCONST bool operator<(const ModInt &x) const {
        return val_ < x.val_;
    } // To use std::map<ModInt, T>
    friend std::istream &operator>>(std::istream &is, ModInt &x) {
        lint t;
        return is >> t, x = ModInt(t), is;
    }
    MDCONST friend std::ostream &operator<<(std::ostream &os, const ModInt &x) {
        return os << x.val_;
    }
    MDCONST ModInt pow(lint n) const {
        ModInt ans = 1, tmp = *this;
        while (n) {
            if (n & 1) ans *= tmp;
            tmp *= tmp, n >>= 1;
        }
        return ans;
    }

    static std::vector<ModInt> facs, facinvs, invs;
    MDCONST static void _precalculation(int N) {
        int l0 = facs.size();
        if (N > md) N = md;
        if (N <= l0) return;
        facs.resize(N), facinvs.resize(N), invs.resize(N);
        for (int i = l0; i < N; i++) facs[i] = facs[i - 1] * i;
        facinvs[N - 1] = facs.back().pow(md - 2);
        for (int i = N - 2; i >= l0; i--) facinvs[i] = facinvs[i + 1] * (i + 1);
        for (int i = N - 1; i >= l0; i--) invs[i] = facinvs[i] * facs[i - 1];
    }
    MDCONST ModInt inv() const {
        if (this->val_ < std::min(md >> 1, 1 << 21)) {
            if (facs.empty()) facs = {1}, facinvs = {1}, invs = {0};
            while (this->val_ >= int(facs.size())) _precalculation(facs.size() * 2);
            return invs[this->val_];
        } else {
            return this->pow(md - 2);
        }
    }
    MDCONST ModInt fac() const {
        while (this->val_ >= int(facs.size())) _precalculation(facs.size() * 2);
        return facs[this->val_];
    }
    MDCONST ModInt facinv() const {
        while (this->val_ >= int(facs.size())) _precalculation(facs.size() * 2);
        return facinvs[this->val_];
    }
    MDCONST ModInt doublefac() const {
        lint k = (this->val_ + 1) / 2;
        return (this->val_ & 1) ? ModInt(k * 2).fac() / (ModInt(2).pow(k) * ModInt(k).fac())
                                : ModInt(k).fac() * ModInt(2).pow(k);
    }
    MDCONST ModInt nCr(const ModInt &r) const {
        return (this->val_ < r.val_) ? 0 : this->fac() * (*this - r).facinv() * r.facinv();
    }
    MDCONST ModInt nPr(const ModInt &r) const {
        return (this->val_ < r.val_) ? 0 : this->fac() * (*this - r).facinv();
    }

    ModInt sqrt() const {
        if (val_ == 0) return 0;
        if (md == 2) return val_;
        if (pow((md - 1) / 2) != 1) return 0;
        ModInt b = 1;
        while (b.pow((md - 1) / 2) == 1) b += 1;
        int e = 0, m = md - 1;
        while (m % 2 == 0) m >>= 1, e++;
        ModInt x = pow((m - 1) / 2), y = (*this) * x * x;
        x *= (*this);
        ModInt z = b.pow(m);
        while (y != 1) {
            int j = 0;
            ModInt t = y;
            while (t != 1) j++, t *= t;
            z = z.pow(1LL << (e - j - 1));
            x *= z, z *= z, y *= z;
            e = j;
        }
        return ModInt(std::min(x.val_, md - x.val_));
    }
};
template <int md> std::vector<ModInt<md>> ModInt<md>::facs = {1};
template <int md> std::vector<ModInt<md>> ModInt<md>::facinvs = {1};
template <int md> std::vector<ModInt<md>> ModInt<md>::invs = {0};

using mint = ModInt<998244353>;

// Integer convolution for arbitrary mod
// with NTT (and Garner's algorithm) for ModInt / ModIntRuntime class.
// We skip Garner's algorithm if `skip_garner` is true or mod is in `nttprimes`.
// input: a (size: n), b (size: m)
// return: vector (size: n + m - 1)
template <typename MODINT>
std::vector<MODINT> nttconv(std::vector<MODINT> a, std::vector<MODINT> b, bool skip_garner);

constexpr int nttprimes[3] = {998244353, 167772161, 469762049};

// Integer FFT (Fast Fourier Transform) for ModInt class
// (Also known as Number Theoretic Transform, NTT)
// is_inverse: inverse transform
// ** Input size must be 2^n **
template <typename MODINT> void ntt(std::vector<MODINT> &a, bool is_inverse = false) {
    int n = a.size();
    if (n == 1) return;
    static const int mod = MODINT::mod();
    static const MODINT root = MODINT::get_primitive_root();
    assert(__builtin_popcount(n) == 1 and (mod - 1) % n == 0);

    static std::vector<MODINT> w{1}, iw{1};
    for (int m = w.size(); m < n / 2; m *= 2) {
        MODINT dw = root.pow((mod - 1) / (4 * m)), dwinv = 1 / dw;
        w.resize(m * 2), iw.resize(m * 2);
        for (int i = 0; i < m; i++) w[m + i] = w[i] * dw, iw[m + i] = iw[i] * dwinv;
    }

    if (!is_inverse) {
        for (int m = n; m >>= 1;) {
            for (int s = 0, k = 0; s < n; s += 2 * m, k++) {
                for (int i = s; i < s + m; i++) {
                    MODINT x = a[i], y = a[i + m] * w[k];
                    a[i] = x + y, a[i + m] = x - y;
                }
            }
        }
    } else {
        for (int m = 1; m < n; m *= 2) {
            for (int s = 0, k = 0; s < n; s += 2 * m, k++) {
                for (int i = s; i < s + m; i++) {
                    MODINT x = a[i], y = a[i + m];
                    a[i] = x + y, a[i + m] = (x - y) * iw[k];
                }
            }
        }
        int n_inv = MODINT(n).inv().val();
        for (auto &v : a) v *= n_inv;
    }
}
template <int MOD>
std::vector<ModInt<MOD>> nttconv_(const std::vector<int> &a, const std::vector<int> &b) {
    int sz = a.size();
    assert(a.size() == b.size() and __builtin_popcount(sz) == 1);
    std::vector<ModInt<MOD>> ap(sz), bp(sz);
    for (int i = 0; i < sz; i++) ap[i] = a[i], bp[i] = b[i];
    ntt(ap, false);
    if (a == b)
        bp = ap;
    else
        ntt(bp, false);
    for (int i = 0; i < sz; i++) ap[i] *= bp[i];
    ntt(ap, true);
    return ap;
}
long long garner_ntt_(int r0, int r1, int r2, int mod) {
    using mint2 = ModInt<nttprimes[2]>;
    static const long long m01 = 1LL * nttprimes[0] * nttprimes[1];
    static const long long m0_inv_m1 = ModInt<nttprimes[1]>(nttprimes[0]).inv().val();
    static const long long m01_inv_m2 = mint2(m01).inv().val();

    int v1 = (m0_inv_m1 * (r1 + nttprimes[1] - r0)) % nttprimes[1];
    auto v2 = (mint2(r2) - r0 - mint2(nttprimes[0]) * v1) * m01_inv_m2;
    return (r0 + 1LL * nttprimes[0] * v1 + m01 % mod * v2.val()) % mod;
}
template <typename MODINT>
std::vector<MODINT> nttconv(std::vector<MODINT> a, std::vector<MODINT> b, bool skip_garner) {
    if (a.empty() or b.empty()) return {};
    int sz = 1, n = a.size(), m = b.size();
    while (sz < n + m) sz <<= 1;
    if (sz <= 16) {
        std::vector<MODINT> ret(n + m - 1);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) ret[i + j] += a[i] * b[j];
        }
        return ret;
    }
    int mod = MODINT::mod();
    if (skip_garner or
        std::find(std::begin(nttprimes), std::end(nttprimes), mod) != std::end(nttprimes)) {
        a.resize(sz), b.resize(sz);
        if (a == b) {
            ntt(a, false);
            b = a;
        } else {
            ntt(a, false), ntt(b, false);
        }
        for (int i = 0; i < sz; i++) a[i] *= b[i];
        ntt(a, true);
        a.resize(n + m - 1);
    } else {
        std::vector<int> ai(sz), bi(sz);
        for (int i = 0; i < n; i++) ai[i] = a[i].val();
        for (int i = 0; i < m; i++) bi[i] = b[i].val();
        auto ntt0 = nttconv_<nttprimes[0]>(ai, bi);
        auto ntt1 = nttconv_<nttprimes[1]>(ai, bi);
        auto ntt2 = nttconv_<nttprimes[2]>(ai, bi);
        a.resize(n + m - 1);
        for (int i = 0; i < n + m - 1; i++)
            a[i] = garner_ntt_(ntt0[i].val(), ntt1[i].val(), ntt2[i].val(), mod);
    }
    return a;
}

template <typename MODINT>
std::vector<MODINT> nttconv(const std::vector<MODINT> &a, const std::vector<MODINT> &b) {
    return nttconv<MODINT>(a, b, false);
}

#include <algorithm>
#include <cassert>
#include <vector>

// Formal Power Series (形式的冪級数) based on ModInt<mod> / ModIntRuntime
// Reference: https://ei1333.github.io/luzhiled/snippets/math/formal-power-series.html
template <typename T> struct FormalPowerSeries : std::vector<T> {
    using std::vector<T>::vector;
    using P = FormalPowerSeries;

    void shrink() {
        while (this->size() and this->back() == T(0)) this->pop_back();
    }

    P operator+(const P &r) const { return P(*this) += r; }
    P operator+(const T &v) const { return P(*this) += v; }
    P operator-(const P &r) const { return P(*this) -= r; }
    P operator-(const T &v) const { return P(*this) -= v; }
    P operator*(const P &r) const { return P(*this) *= r; }
    P operator*(const T &v) const { return P(*this) *= v; }
    P operator/(const P &r) const { return P(*this) /= r; }
    P operator/(const T &v) const { return P(*this) /= v; }
    P operator%(const P &r) const { return P(*this) %= r; }

    P &operator+=(const P &r) {
        if (r.size() > this->size()) this->resize(r.size());
        for (int i = 0; i < (int)r.size(); i++) (*this)[i] += r[i];
        shrink();
        return *this;
    }
    P &operator+=(const T &v) {
        if (this->empty()) this->resize(1);
        (*this)[0] += v;
        shrink();
        return *this;
    }
    P &operator-=(const P &r) {
        if (r.size() > this->size()) this->resize(r.size());
        for (int i = 0; i < (int)r.size(); i++) (*this)[i] -= r[i];
        shrink();
        return *this;
    }
    P &operator-=(const T &v) {
        if (this->empty()) this->resize(1);
        (*this)[0] -= v;
        shrink();
        return *this;
    }
    P &operator*=(const T &v) {
        for (auto &x : (*this)) x *= v;
        shrink();
        return *this;
    }
    P &operator*=(const P &r) {
        if (this->empty() || r.empty())
            this->clear();
        else {
            auto ret = nttconv(*this, r);
            *this = P(ret.begin(), ret.end());
        }
        return *this;
    }
    P &operator%=(const P &r) {
        *this -= *this / r * r;
        shrink();
        return *this;
    }
    P operator-() const {
        P ret = *this;
        for (auto &v : ret) v = -v;
        return ret;
    }
    P &operator/=(const T &v) {
        assert(v != T(0));
        for (auto &x : (*this)) x /= v;
        return *this;
    }
    P &operator/=(const P &r) {
        if (this->size() < r.size()) {
            this->clear();
            return *this;
        }
        int n = (int)this->size() - r.size() + 1;
        return *this = (reversed().pre(n) * r.reversed().inv(n)).pre(n).reversed(n);
    }
    P pre(int sz) const {
        P ret(this->begin(), this->begin() + std::min((int)this->size(), sz));
        ret.shrink();
        return ret;
    }
    P operator>>(int sz) const {
        if ((int)this->size() <= sz) return {};
        return P(this->begin() + sz, this->end());
    }
    P operator<<(int sz) const {
        if (this->empty()) return {};
        P ret(*this);
        ret.insert(ret.begin(), sz, T(0));
        return ret;
    }

    P reversed(int deg = -1) const {
        assert(deg >= -1);
        P ret(*this);
        if (deg != -1) ret.resize(deg, T(0));
        reverse(ret.begin(), ret.end());
        ret.shrink();
        return ret;
    }

    P differential() const { // formal derivative (differential) of f.p.s.
        const int n = (int)this->size();
        P ret(std::max(0, n - 1));
        for (int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i);
        return ret;
    }

    P integral() const {
        const int n = (int)this->size();
        P ret(n + 1);
        ret[0] = T(0);
        for (int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1);
        return ret;
    }

    P inv(int deg) const {
        assert(deg >= -1);
        assert(this->size() and ((*this)[0]) != T(0)); // Requirement: F(0) != 0
        const int n = this->size();
        if (deg == -1) deg = n;
        P ret({T(1) / (*this)[0]});
        for (int i = 1; i < deg; i <<= 1) {
            auto h = (pre(i << 1) * ret).pre(i << 1) >> i;
            auto tmp = (-h * ret).pre(i);
            ret.insert(ret.end(), tmp.begin(), tmp.end());
            ret.resize(i << 1);
        }
        ret = ret.pre(deg);
        ret.shrink();
        return ret;
    }

    P log(int deg = -1) const {
        assert(deg >= -1);
        assert(this->size() and ((*this)[0]) == T(1)); // Requirement: F(0) = 1
        const int n = (int)this->size();
        if (deg == 0) return {};
        if (deg == -1) deg = n;
        return (this->differential() * this->inv(deg)).pre(deg - 1).integral();
    }

    P sqrt(int deg = -1) const {
        assert(deg >= -1);
        const int n = (int)this->size();
        if (deg == -1) deg = n;
        if (this->empty()) return {};
        if ((*this)[0] == T(0)) {
            for (int i = 1; i < n; i++)
                if ((*this)[i] != T(0)) {
                    if ((i & 1) or deg - i / 2 <= 0) return {};
                    return (*this >> i).sqrt(deg - i / 2) << (i / 2);
                }
            return {};
        }
        T sqrtf0 = (*this)[0].sqrt();
        if (sqrtf0 == T(0)) return {};

        P y = (*this) / (*this)[0], ret({T(1)});
        T inv2 = T(1) / T(2);
        for (int i = 1; i < deg; i <<= 1) ret = (ret + y.pre(i << 1) * ret.inv(i << 1)) * inv2;
        return ret.pre(deg) * sqrtf0;
    }

    P exp(int deg = -1) const {
        assert(deg >= -1);
        assert(this->empty() or ((*this)[0]) == T(0)); // Requirement: F(0) = 0
        const int n = (int)this->size();
        if (deg == -1) deg = n;
        P ret({T(1)});
        for (int i = 1; i < deg; i <<= 1) {
            ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1);
        }
        return ret.pre(deg);
    }

    P pow(long long k, int deg = -1) const {
        assert(deg >= -1);
        const int n = (int)this->size();
        if (deg == -1) deg = n;

        if (k == 0) {
            P ret(deg);
            if (deg >= 1) ret[0] = T(1);
            ret.shrink();
            return ret;
        }

        for (int i = 0; i < n; i++) {
            if ((*this)[i] != T(0)) {
                T rev = T(1) / (*this)[i];
                P C = (*this) * rev, D(n - i);
                for (int j = i; j < n; j++) D[j - i] = C.coeff(j);
                D = (D.log(deg) * T(k)).exp(deg) * (*this)[i].pow(k);
                if (__int128(k) * i > deg) return {};
                P E(deg);
                long long S = i * k;
                for (int j = 0; j + S < deg and j < (int)D.size(); j++) E[j + S] = D[j];
                E.shrink();
                return E;
            }
        }
        return *this;
    }

    // Calculate f(X + c) from f(X), O(NlogN)
    P shift(T c) const {
        const int n = (int)this->size();
        P ret = *this;
        for (int i = 0; i < n; i++) ret[i] *= T(i).fac();
        std::reverse(ret.begin(), ret.end());
        P exp_cx(n, 1);
        for (int i = 1; i < n; i++) exp_cx[i] = exp_cx[i - 1] * c / i;
        ret = (ret * exp_cx), ret.resize(n);
        std::reverse(ret.begin(), ret.end());
        for (int i = 0; i < n; i++) ret[i] /= T(i).fac();
        return ret;
    }

    T coeff(int i) const {
        if ((int)this->size() <= i or i < 0) return T(0);
        return (*this)[i];
    }

    T eval(T x) const {
        T ret = 0, w = 1;
        for (auto &v : *this) ret += w * v, w *= x;
        return ret;
    }
};

// multipoint polynomial evaluation
// input: xs = [x_0, ..., x_{N - 1}]: points to evaluate
//        f = \sum_i^M f_i x^i
// Complexity: O(N (lgN)^2) building, O(N (lgN)^2 + M lg M) evaluation
template <typename Tfield> struct MultipointEvaluation {
    int nx;
    using polynomial = FormalPowerSeries<Tfield>;
    std::vector<polynomial> segtree;
    MultipointEvaluation(const std::vector<Tfield> &xs) : nx(xs.size()) {
        segtree.resize(nx * 2 - 1);
        for (int i = 0; i < nx; i++) { segtree[nx - 1 + i] = {-xs[i], 1}; }
        for (int i = nx - 2; i >= 0; i--) { segtree[i] = segtree[2 * i + 1] * segtree[2 * i + 2]; }
    }
    std::vector<Tfield> ret;
    void _eval_rec(polynomial f, int now) {
        f %= segtree[now];
        if (now - (nx - 1) >= 0) {
            ret[now - (nx - 1)] = f.coeff(0);
            return;
        }
        _eval_rec(f, 2 * now + 1);
        _eval_rec(f, 2 * now + 2);
    }
    std::vector<Tfield> evaluate_polynomial(const polynomial &f) {
        ret.resize(nx);
        _eval_rec(f, 0);
        return ret;
    }
    std::vector<Tfield> evaluate_polynomial(const std::vector<Tfield> &f) {
        return evaluate_polynomial(polynomial(f.begin(), f.end()));
    }

    std::vector<Tfield> _interpolate_coeffs;
    polynomial _rec_interpolation(int now, const std::vector<Tfield> &ys) const {
        int i = now - (nx - 1);
        if (i >= 0) return {ys[i]};
        auto retl = _rec_interpolation(2 * now + 1, ys);
        auto retr = _rec_interpolation(2 * now + 2, ys);
        return retl * segtree[2 * now + 2] + retr * segtree[2 * now + 1];
    }
    std::vector<Tfield> polynomial_interpolation(std::vector<Tfield> ys) {
        assert(nx == int(ys.size()));
        if (_interpolate_coeffs.empty()) {
            _interpolate_coeffs = evaluate_polynomial(segtree[0].differential());
            for (auto &x : _interpolate_coeffs) x = x.inv();
        }
        for (int i = 0; i < nx; i++) ys[i] *= _interpolate_coeffs[i];
        return _rec_interpolation(0, ys);
    }
};


mint calc(int sz, const vector<int> &A) {
    const int N = A.size();
    int up = 0;
    if (sz < N) up = A.at(N - sz - 1);

    if (up == 0) {
        mint ans = 1;
        for (int a : A) if (a >= sz) ans *= a;
        return ans;
    }

    auto rec = [&](auto &&self, int l, int r) -> vector<mint> {
        if (l + 1 == r) {
            return {A.at(l), -1};
        } else {
            const int c = (l + r) / 2;
            return nttconv(self(self, l, c), self(self, c, r));
        }
    };

    auto f = rec(rec, N - sz, N);
    dbg(f);

    vector<mint> xs;
    REP(i, up + 1) xs.push_back(i);
    MultipointEvaluation me(xs);
    auto ys = me.evaluate_polynomial(f);
    dbg(ys);

    mint ret = 0;
    REP(i, ys.size()) ret += ys.at(i) * (i % 2 ? -1 : 1) * mint(up).nCr(i);
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    dbg(A);
    vector<int> B(N);
    REP(i, N) chmax(B.at(N - A.at(i)), N - i);
    FOR(i, 1, N) chmax(B.at(i), B.at(i - 1));
    dbg(B);

    int sz = 1;
    while (sz <= N and A.at(N - sz) >= sz) ++sz;
    --sz;
    dbg(sz);

    mint ret = -mint(sz).fac();
    ret += calc(sz, A);
    ret += calc(sz, B);
    cout << sz << ' ' << ret << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3436kb

input:

3
1 2 3

output:

2 6

result:

ok 2 number(s): "2 6"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3416kb

input:

1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3440kb

input:

2
1 1

output:

1 2

result:

ok 2 number(s): "1 2"

Test #4:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

2
2 2

output:

2 6

result:

ok 2 number(s): "2 6"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

3
1 1 1

output:

1 3

result:

ok 2 number(s): "1 3"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3504kb

input:

3
2 2 2

output:

2 9

result:

ok 2 number(s): "2 9"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

3
3 3 3

output:

3 48

result:

ok 2 number(s): "3 48"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

5
1 1 3 3 4

output:

3 47

result:

ok 2 number(s): "3 47"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3444kb

input:

10
2 4 5 5 5 5 6 8 8 10

output:

5 864

result:

ok 2 number(s): "5 864"

Test #10:

score: 0
Accepted
time: 2ms
memory: 3424kb

input:

30
6 8 9 9 9 10 13 14 15 15 16 17 17 18 20 22 22 23 23 24 24 25 25 25 27 28 28 29 29 30

output:

17 986189864

result:

ok 2 number(s): "17 986189864"

Test #11:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

123
1 1 1 2 2 3 3 6 6 7 7 7 8 8 9 9 10 10 10 11 12 12 12 13 14 14 14 14 16 17 17 17 17 17 18 19 20 20 21 21 22 22 22 23 23 23 25 25 26 27 27 28 28 28 28 29 29 30 31 31 31 32 33 33 33 34 35 35 35 36 37 37 38 39 39 39 39 40 41 41 42 42 42 43 44 48 48 50 52 53 55 56 57 57 57 58 65 68 71 74 75 76 76 82 ...

output:

42 287179924

result:

ok 2 number(s): "42 287179924"

Test #12:

score: 0
Accepted
time: 3ms
memory: 3516kb

input:

1234
1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 4 5 5 5 5 6 6 7 7 7 7 7 7 7 8 8 8 8 9 9 10 10 10 11 11 11 11 11 12 13 13 14 14 15 15 15 15 16 16 16 17 17 17 18 18 18 19 19 19 19 19 19 19 19 19 19 20 20 20 21 21 21 21 21 22 22 22 23 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 26 26 26 26 ...

output:

239 98119841

result:

ok 2 number(s): "239 98119841"

Test #13:

score: 0
Accepted
time: 30ms
memory: 3852kb

input:

2345
1 1 2 2 2 7 7 9 9 9 9 15 17 19 19 22 23 24 25 29 29 29 30 31 32 33 35 37 39 41 42 42 43 43 44 46 46 46 47 48 48 50 51 51 52 53 53 54 55 56 57 58 58 60 61 63 63 64 65 65 65 66 67 67 67 69 69 69 70 71 72 72 73 73 74 75 75 77 77 79 83 85 86 88 90 90 91 93 94 97 99 104 106 107 108 108 109 109 110 1...

output:

1239 588926916

result:

ok 2 number(s): "1239 588926916"

Test #14:

score: 0
Accepted
time: 64ms
memory: 4136kb

input:

3456
4 7 8 8 9 19 20 21 22 23 23 27 29 29 32 32 33 43 45 50 52 52 55 58 58 58 60 62 66 67 68 69 71 74 74 76 77 79 82 82 87 87 88 91 93 95 96 97 99 102 104 106 107 108 121 121 123 126 127 131 137 138 139 142 145 147 152 156 157 159 161 165 166 170 170 172 174 175 178 182 183 185 186 189 190 195 195 1...

output:

2239 24387925

result:

ok 2 number(s): "2239 24387925"

Test #15:

score: 0
Accepted
time: 93ms
memory: 4284kb

input:

4456
4 7 10 10 22 24 29 33 33 34 35 37 40 41 47 48 55 61 61 65 69 71 76 91 95 99 105 105 105 110 112 113 117 117 120 121 122 123 125 127 130 134 135 138 140 141 142 142 144 150 153 154 157 162 165 169 170 170 174 175 176 178 197 198 198 201 208 211 211 212 214 214 215 217 220 224 224 225 230 231 232...

output:

3239 904395650

result:

ok 2 number(s): "3239 904395650"

Test #16:

score: 0
Accepted
time: 135ms
memory: 4748kb

input:

5000
1 5 7 8 24 28 36 47 50 56 59 64 66 85 89 94 95 95 98 108 110 117 122 155 157 158 163 172 172 179 186 197 198 220 236 251 254 254 256 265 287 288 298 302 306 312 327 336 343 344 345 348 350 360 363 364 382 382 390 399 402 406 412 421 425 435 442 445 450 451 453 478 481 490 491 496 499 500 500 50...

output:

4239 328488156

result:

ok 2 number(s): "4239 328488156"

Test #17:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

5000
5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 ...

output:

5000 317554850

result:

ok 2 number(s): "5000 317554850"

Test #18:

score: 0
Accepted
time: 107ms
memory: 4512kb

input:

5000
4123 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 ...

output:

4999 609985488

result:

ok 2 number(s): "4999 609985488"

Test #19:

score: 0
Accepted
time: 134ms
memory: 4660kb

input:

5000
1501 1689 3190 3774 4708 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 4995 ...

output:

4995 577669110

result:

ok 2 number(s): "4995 577669110"

Test #20:

score: 0
Accepted
time: 156ms
memory: 4652kb

input:

5000
63 107 213 432 444 500 519 543 591 699 704 825 930 1027 1141 1256 1287 1347 1487 1547 1649 1651 1674 1696 1701 1716 1738 1849 1880 1919 1965 1973 1989 2000 2052 2063 2094 2112 2155 2288 2459 2527 2600 2607 2663 2703 2779 2968 3002 3041 3050 3092 3097 3098 3352 3378 3440 3525 3613 3626 3712 3742...

output:

4913 376487851

result:

ok 2 number(s): "4913 376487851"

Test #21:

score: 0
Accepted
time: 147ms
memory: 4764kb

input:

5000
2 9 17 19 50 63 63 82 83 87 92 101 126 136 172 182 187 201 208 214 222 233 242 256 271 272 284 288 294 300 303 323 353 354 418 430 463 500 501 511 543 550 554 568 569 570 570 577 578 590 654 671 680 695 702 705 716 722 732 736 776 783 785 794 797 808 835 855 859 866 891 896 924 934 942 953 961 ...

output:

4567 930123987

result:

ok 2 number(s): "4567 930123987"

Test #22:

score: 0
Accepted
time: 125ms
memory: 4636kb

input:

5000
9 16 18 19 21 27 44 49 53 63 66 70 84 95 95 101 103 107 107 110 113 113 114 118 126 131 132 135 141 155 162 162 162 168 181 183 184 184 190 191 191 194 195 196 201 203 210 210 211 214 215 219 221 222 232 241 243 250 250 252 253 256 258 258 258 263 271 272 274 282 283 287 292 293 296 308 315 317...

output:

4097 266880018

result:

ok 2 number(s): "4097 266880018"

Test #23:

score: 0
Accepted
time: 124ms
memory: 4644kb

input:

5000
1 5 11 11 13 25 41 41 52 55 60 64 65 65 71 77 90 91 92 99 106 109 112 118 120 128 130 135 136 139 148 151 152 152 163 168 170 172 176 178 184 187 191 195 197 198 204 205 206 225 233 234 235 236 242 247 255 256 258 262 263 263 267 271 271 278 288 289 290 296 299 303 304 305 309 311 318 325 341 3...

output:

4096 441159088

result:

ok 2 number(s): "4096 441159088"

Test #24:

score: 0
Accepted
time: 123ms
memory: 4568kb

input:

5000
1 2 9 10 18 19 21 23 24 38 39 39 48 54 58 60 62 66 85 86 91 97 97 103 103 106 109 112 117 122 124 126 148 148 149 152 152 156 158 166 166 172 185 188 190 199 201 202 203 208 208 208 226 232 238 252 258 262 267 280 281 294 295 302 306 307 308 308 309 309 325 329 329 356 366 366 367 373 381 384 3...

output:

4095 288197876

result:

ok 2 number(s): "4095 288197876"

Test #25:

score: 0
Accepted
time: 87ms
memory: 4268kb

input:

5000
1 8 8 12 13 15 19 20 21 22 25 26 31 31 34 35 35 38 40 41 45 48 51 51 52 54 56 57 58 61 62 62 64 64 64 65 67 68 68 68 69 70 74 76 76 76 78 79 79 80 85 86 89 89 90 91 98 101 102 109 110 114 115 115 115 119 120 122 122 126 129 130 131 131 131 134 136 137 139 140 141 142 144 147 150 150 151 152 154...

output:

3123 952629946

result:

ok 2 number(s): "3123 952629946"

Test #26:

score: 0
Accepted
time: 24ms
memory: 3800kb

input:

5000
1 1 1 1 1 2 2 3 3 4 4 4 4 4 4 4 5 5 5 6 6 6 7 7 7 7 7 8 8 9 9 9 9 10 10 10 10 10 11 11 11 11 11 12 12 12 12 13 13 13 14 14 15 15 15 16 16 17 17 17 17 18 18 18 18 18 18 18 18 18 19 19 19 20 20 20 21 21 22 22 22 22 22 22 22 23 23 23 23 24 24 24 24 26 26 26 26 27 27 27 28 28 28 29 29 29 29 30 30 3...

output:

1123 702281788

result:

ok 2 number(s): "1123 702281788"

Test #27:

score: 0
Accepted
time: 4ms
memory: 3528kb

input:

5000
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 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4...

output:

123 482123450

result:

ok 2 number(s): "123 482123450"

Test #28:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

5000
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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

42 966786798

result:

ok 2 number(s): "42 966786798"

Test #29:

score: 0
Accepted
time: 2ms
memory: 3432kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

13 237554682

result:

ok 2 number(s): "13 237554682"

Test #30:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

7 5040

result:

ok 2 number(s): "7 5040"

Test #31:

score: 0
Accepted
time: 2ms
memory: 3488kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

5 120

result:

ok 2 number(s): "5 120"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

3 6

result:

ok 2 number(s): "3 6"

Test #33:

score: 0
Accepted
time: 2ms
memory: 3544kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

2 2

result:

ok 2 number(s): "2 2"

Test #34:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

1 1

result:

ok 2 number(s): "1 1"

Test #35:

score: 0
Accepted
time: 70ms
memory: 4148kb

input:

5000
1 3 3 3 4 4 5 5 5 5 8 8 8 9 9 9 10 13 14 22 22 22 22 24 24 25 27 28 28 28 32 34 35 35 36 36 38 38 40 41 41 42 46 46 46 47 48 48 48 48 50 52 52 53 55 56 56 57 58 59 60 62 62 63 63 65 67 68 70 72 80 82 83 83 84 86 87 88 89 89 90 91 91 91 92 95 95 96 97 97 100 100 100 100 101 102 104 105 105 107 1...

output:

2496 644254912

result:

ok 2 number(s): "2496 644254912"

Test #36:

score: 0
Accepted
time: 154ms
memory: 4588kb

input:

5000
4999 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 ...

output:

4999 648815172

result:

ok 2 number(s): "4999 648815172"

Test #37:

score: 0
Accepted
time: 157ms
memory: 4556kb

input:

5000
4913 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 ...

output:

4999 672978716

result:

ok 2 number(s): "4999 672978716"

Test #38:

score: 0
Accepted
time: 154ms
memory: 4648kb

input:

5000
111 598 627 1600 3510 4414 4855 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 4993 499...

output:

4993 778016618

result:

ok 2 number(s): "4993 778016618"

Test #39:

score: 0
Accepted
time: 147ms
memory: 4744kb

input:

5000
31 56 58 60 100 144 151 166 188 192 249 254 254 254 258 259 308 325 337 355 362 374 424 433 438 451 460 491 491 503 507 513 531 537 539 539 544 566 568 596 605 629 635 636 685 693 702 713 726 735 737 744 754 778 780 781 793 801 811 833 838 838 845 868 876 877 897 923 931 935 951 956 968 978 981...

output:

4712 291142969

result:

ok 2 number(s): "4712 291142969"

Test #40:

score: 0
Accepted
time: 22ms
memory: 4216kb

input:

5000
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 1 1 1 1 1 1 1 1...

output:

4712 803514123

result:

ok 2 number(s): "4712 803514123"

Test #41:

score: 0
Accepted
time: 34ms
memory: 4252kb

input:

5000
3 5 6 6 7 7 8 10 10 10 12 12 13 13 13 14 15 16 16 16 16 19 19 20 20 21 23 24 25 26 26 26 27 28 29 30 31 31 32 32 33 33 35 35 37 38 38 39 40 41 41 42 42 42 43 44 46 46 46 48 48 50 51 51 52 52 53 53 53 55 56 57 57 57 59 60 60 62 63 63 64 65 65 67 67 67 69 69 71 71 72 72 72 73 73 74 74 75 76 76 76...

output:

4712 234298773

result:

ok 2 number(s): "4712 234298773"

Test #42:

score: 0
Accepted
time: 202ms
memory: 5108kb

input:

12345
1 2 7 9 9 14 15 18 18 20 23 27 27 27 28 28 29 29 30 32 32 32 33 33 34 34 34 35 35 35 36 37 37 37 38 40 40 43 45 47 47 49 50 52 55 56 58 59 59 59 62 64 67 68 68 69 69 71 72 73 74 77 77 80 81 81 82 83 83 87 88 88 89 89 89 91 91 93 94 94 94 95 96 96 97 98 99 99 100 101 101 102 104 104 106 107 107...

output:

6177 12065098

result:

ok 2 number(s): "6177 12065098"

Test #43:

score: 0
Accepted
time: 728ms
memory: 8156kb

input:

34567
4 4 5 6 6 6 10 11 12 14 14 15 15 16 17 19 19 21 22 28 28 30 31 31 33 33 34 34 34 35 35 36 38 38 38 41 41 42 43 44 44 45 46 49 49 49 50 51 52 53 53 54 54 56 57 57 59 59 60 62 62 64 65 66 68 70 73 74 75 75 76 76 79 80 81 83 83 83 84 86 87 88 90 91 91 91 92 93 93 95 95 95 96 96 96 96 98 99 99 100...

output:

17301 238069256

result:

ok 2 number(s): "17301 238069256"

Test #44:

score: 0
Accepted
time: 1778ms
memory: 14180kb

input:

77777
2 4 5 5 7 8 9 10 11 12 12 13 13 13 14 14 14 14 15 15 16 19 19 23 25 27 28 28 29 29 30 32 32 33 34 34 35 35 36 38 39 39 40 41 41 42 42 45 47 50 50 51 51 52 54 54 54 54 56 56 56 57 58 58 59 59 62 63 64 65 66 67 68 68 69 71 71 72 73 76 78 80 81 81 83 83 84 84 84 86 89 89 89 94 95 95 96 97 98 99 9...

output:

38737 713424578

result:

ok 2 number(s): "38737 713424578"

Test #45:

score: 0
Accepted
time: 2388ms
memory: 16852kb

input:

100000
2 3 4 4 6 6 7 7 7 11 11 12 13 13 13 16 17 17 18 18 20 21 21 23 23 25 25 25 26 27 28 29 32 32 32 33 33 33 35 35 37 37 39 39 40 43 43 45 47 48 49 50 52 53 53 54 54 55 55 56 56 56 56 57 58 59 61 63 66 66 68 69 71 71 74 74 76 77 80 80 82 82 83 84 84 87 87 87 88 88 89 91 91 92 92 96 96 97 98 99 10...

output:

49978 801069203

result:

ok 2 number(s): "49978 801069203"

Test #46:

score: 0
Accepted
time: 3273ms
memory: 21912kb

input:

131071
1 3 4 5 6 7 7 7 10 10 11 11 13 15 15 19 21 22 22 24 25 25 27 29 29 31 32 33 35 38 40 41 43 44 44 45 46 46 46 46 50 51 51 52 53 53 53 55 55 56 58 61 61 61 62 64 65 66 68 68 69 69 69 70 71 72 72 73 73 74 75 76 77 77 77 77 78 79 81 82 82 85 86 87 89 89 92 96 97 98 98 101 101 102 103 104 105 105 ...

output:

65535 798765225

result:

ok 2 number(s): "65535 798765225"

Test #47:

score: 0
Accepted
time: 7ms
memory: 4052kb

input:

131071
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 1 1 1 1 1 1 1...

output:

1 1

result:

ok 2 number(s): "1 1"

Test #48:

score: 0
Accepted
time: 9ms
memory: 4072kb

input:

131071
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 1 1 1 1 1 1 1...

output:

2 2

result:

ok 2 number(s): "2 2"

Test #49:

score: 0
Accepted
time: 1ms
memory: 4180kb

input:

131071
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 1 1 1 1 1 1 1...

output:

5 120

result:

ok 2 number(s): "5 120"

Test #50:

score: 0
Accepted
time: 5ms
memory: 4092kb

input:

131071
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 1 1 1 1 1 1 1...

output:

14 331032489

result:

ok 2 number(s): "14 331032489"

Test #51:

score: 0
Accepted
time: 6ms
memory: 4112kb

input:

131071
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 1 1 1 1 1 1 1...

output:

42 966786798

result:

ok 2 number(s): "42 966786798"

Test #52:

score: 0
Accepted
time: 9ms
memory: 4132kb

input:

131071
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 1 1 1 1 1 1 1...

output:

132 477815844

result:

ok 2 number(s): "132 477815844"

Test #53:

score: 0
Accepted
time: 12ms
memory: 4324kb

input:

131071
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 1 1 1 1 1 1 1...

output:

429 247699365

result:

ok 2 number(s): "429 247699365"

Test #54:

score: 0
Accepted
time: 27ms
memory: 4456kb

input:

131071
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 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...

output:

1234 665664101

result:

ok 2 number(s): "1234 665664101"

Test #55:

score: 0
Accepted
time: 180ms
memory: 5652kb

input:

131071
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 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7...

output:

5555 303875205

result:

ok 2 number(s): "5555 303875205"

Test #56:

score: 0
Accepted
time: 481ms
memory: 7448kb

input:

131071
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 13 13 13 13 13 14 14 14 14 14 15 15 15 15 15 15 15 15 15 ...

output:

12345 967550664

result:

ok 2 number(s): "12345 967550664"

Test #57:

score: 0
Accepted
time: 1622ms
memory: 13760kb

input:

131071
2 2 2 2 3 3 4 4 4 5 5 6 6 7 7 7 8 9 9 9 10 10 10 10 10 10 11 11 12 12 13 13 13 14 14 14 16 17 17 18 18 18 19 19 19 20 21 21 22 22 22 23 23 23 24 24 24 24 25 25 25 25 26 26 26 26 26 27 27 28 28 28 29 29 29 30 30 31 32 32 32 33 33 33 34 35 35 35 36 36 37 37 37 38 38 39 40 40 41 41 41 42 42 42 4...

output:

34567 986889809

result:

ok 2 number(s): "34567 986889809"

Test #58:

score: 0
Accepted
time: 2857ms
memory: 19308kb

input:

131071
1 4 4 5 5 6 6 7 7 7 7 8 8 9 9 10 10 11 11 11 11 13 13 14 16 18 21 22 24 25 25 26 26 27 27 29 32 33 33 35 36 37 37 37 38 39 39 40 40 40 40 41 42 43 45 45 45 45 45 46 48 50 50 50 50 50 51 52 53 53 55 55 56 57 57 62 64 65 66 67 67 67 68 69 70 70 72 73 73 73 75 77 78 78 78 79 80 80 81 82 82 82 82...

output:

61231 522404009

result:

ok 2 number(s): "61231 522404009"

Test #59:

score: 0
Accepted
time: 3989ms
memory: 25676kb

input:

131071
1 1 5 10 11 12 14 15 15 17 18 18 18 21 22 23 24 25 27 27 28 29 29 31 31 34 39 39 41 43 46 47 47 47 49 50 52 53 53 53 58 59 62 64 65 66 66 67 67 68 70 71 71 73 75 77 79 80 80 82 84 85 85 87 87 87 89 89 94 96 99 100 103 103 107 107 108 108 111 113 113 116 116 117 117 123 123 124 125 125 129 131...

output:

77777 113007549

result:

ok 2 number(s): "77777 113007549"

Test #60:

score: 0
Accepted
time: 5301ms
memory: 30236kb

input:

131071
2 4 16 26 31 36 38 40 48 50 51 52 58 64 74 75 75 78 82 84 93 93 94 96 101 102 102 104 107 108 118 118 122 127 139 141 145 148 156 168 170 175 181 183 183 186 187 195 198 198 199 199 201 204 216 217 220 227 230 230 231 234 237 239 241 243 244 250 252 254 255 260 261 266 266 269 285 290 293 295...

output:

99230 646212276

result:

ok 2 number(s): "99230 646212276"

Test #61:

score: 0
Accepted
time: 5845ms
memory: 32796kb

input:

131071
7 8 13 51 55 66 67 87 88 90 95 102 116 117 119 128 128 134 161 162 168 172 181 190 191 200 201 223 223 231 233 239 247 256 262 272 291 296 307 314 318 327 330 331 333 333 341 358 358 361 365 366 373 375 377 381 391 393 407 414 414 415 423 431 448 453 454 457 463 480 492 501 509 511 513 520 53...

output:

112345 90940517

result:

ok 2 number(s): "112345 90940517"

Test #62:

score: 0
Accepted
time: 6601ms
memory: 34904kb

input:

131071
20 33 33 60 88 106 106 119 119 121 138 138 139 169 193 199 200 203 220 226 235 258 260 290 303 308 337 350 374 385 391 396 399 413 421 423 481 485 504 571 579 581 584 584 593 600 602 628 654 672 687 730 773 807 814 837 895 909 950 955 965 976 981 1003 1007 1021 1045 1045 1050 1083 1092 1094 1...

output:

123456 269034268

result:

ok 2 number(s): "123456 269034268"

Test #63:

score: 0
Accepted
time: 6683ms
memory: 36204kb

input:

131071
11 312 470 489 561 677 767 843 859 1352 1387 1656 1855 2044 2188 2296 2314 2596 2719 2777 2877 3248 3511 3647 3878 3891 3893 3948 3958 4038 4209 4384 4401 4518 5041 5251 5252 5303 5470 5677 5904 6079 6327 6633 6710 6838 7464 7527 7684 7805 7981 8070 8250 8271 8292 8337 8352 8753 8838 8865 899...

output:

130112 274844737

result:

ok 2 number(s): "130112 274844737"

Test #64:

score: 0
Accepted
time: 6751ms
memory: 36292kb

input:

131071
353 963 1037 1200 1809 3963 4980 5480 6035 8063 8252 9138 9293 9556 10428 11293 11635 11749 11947 12743 13788 14763 15351 15415 16081 16403 16713 16903 17789 18148 18421 18421 19670 20914 21053 22581 23483 23632 24640 26377 26551 27456 27461 27622 28409 29535 29605 29691 29842 30579 30674 314...

output:

130851 17367977

result:

ok 2 number(s): "130851 17367977"

Test #65:

score: 0
Accepted
time: 6721ms
memory: 36336kb

input:

131071
296 1119 1467 4600 5182 11247 14269 15223 20929 21039 21555 22161 22908 27224 29358 30281 32287 35447 35718 39080 41567 44477 44910 45006 47142 48301 48548 48859 48965 55955 56602 58940 59307 59465 61532 64352 66120 71113 72055 76259 76376 78066 79755 84683 87278 87321 90267 90435 90624 92188...

output:

130999 449823232

result:

ok 2 number(s): "130999 449823232"

Test #66:

score: 0
Accepted
time: 6594ms
memory: 35416kb

input:

131071
7556 8071 13415 16058 17088 20870 24304 24830 37901 38580 41995 44508 48161 61543 66311 76101 77252 78293 79557 80639 81548 81584 88739 91485 95407 97742 115137 120544 123887 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042 131042...

output:

131042 314169948

result:

ok 2 number(s): "131042 314169948"

Test #67:

score: 0
Accepted
time: 6384ms
memory: 34228kb

input:

131071
8519 20620 27739 33673 36784 66396 76715 97566 121117 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 131062 1...

output:

131062 823790233

result:

ok 2 number(s): "131062 823790233"

Test #68:

score: 0
Accepted
time: 6015ms
memory: 33044kb

input:

131071
59094 69170 73139 113253 113446 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 131066 13...

output:

131066 817528150

result:

ok 2 number(s): "131066 817528150"

Test #69:

score: 0
Accepted
time: 2437ms
memory: 27764kb

input:

131071
5095 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 131070 1...

output:

131070 933727768

result:

ok 2 number(s): "131070 933727768"

Test #70:

score: 0
Accepted
time: 14ms
memory: 6044kb

input:

131071
131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071...

output:

131071 65855831

result:

ok 2 number(s): "131071 65855831"

Test #71:

score: 0
Accepted
time: 719ms
memory: 19128kb

input:

131071
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 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 131013 13...

output:

131013 573172275

result:

ok 2 number(s): "131013 573172275"

Test #72:

score: 0
Accepted
time: 3726ms
memory: 39964kb

input:

131071
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 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 131014 13...

output:

131013 800326197

result:

ok 2 number(s): "131013 800326197"

Test #73:

score: 0
Accepted
time: 3739ms
memory: 36400kb

input:

131071
1164 3245 6104 9441 18127 18279 22080 25551 27108 28084 34700 36632 41439 41579 43394 44379 47563 48309 48809 50014 50709 58528 61531 67043 67732 70522 70725 73883 74032 75314 79813 82469 83714 84951 88237 88708 90402 91928 93357 94494 94908 95962 96018 99678 100110 102755 102886 103902 10562...

output:

131013 195940380

result:

ok 2 number(s): "131013 195940380"

Test #74:

score: 0
Accepted
time: 6758ms
memory: 36440kb

input:

131071
5858 8601 15570 18840 19352 20927 21563 22382 24578 25143 30291 33672 34919 41238 45265 45438 55818 56787 65752 66625 66702 67349 69212 73422 76562 82206 83311 83376 83400 83671 84813 86888 89148 92992 93042 94841 95231 96056 96372 97107 97695 98630 100494 105980 109254 109707 109945 111181 1...

output:

131013 676303795

result:

ok 2 number(s): "131013 676303795"

Test #75:

score: 0
Accepted
time: 6850ms
memory: 39808kb

input:

131071
131070 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071 131071...

output:

131070 712490707

result:

ok 2 number(s): "131070 712490707"