QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665412#6411. Classical FFT ProblemohwphilAC ✓6422ms73056kbC++1717.2kb2024-10-22 12:26:242024-10-22 12:26:24

Judging History

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

  • [2024-10-22 12:26:24]
  • 评测
  • 测评结果:AC
  • 用时:6422ms
  • 内存:73056kb
  • [2024-10-22 12:26:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()

typedef long long lint;
const long long mod = 119 << 23 | 1;

struct mint {
    int val;
    mint() { val = 0; }
    mint(const lint& v) {
        val = (-mod <= v && v < mod) ? v : v % mod;
        if (val < 0) val += mod;
    }

    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.val; }
    friend bool operator==(const mint& a, const mint& b) { return a.val == b.val; }
    friend bool operator!=(const mint& a, const mint& b) { return !(a == b); }
    friend bool operator<(const mint& a, const mint& b) { return a.val < b.val; }

    mint operator-() const { return mint(-val); }
    mint& operator+=(const mint& m) { if ((val += m.val) >= mod) val -= mod; return *this; }
    mint& operator-=(const mint& m) { if ((val -= m.val) < 0) val += mod; return *this; }
    mint& operator*=(const mint& m) { val = (lint)val*m.val%mod; return *this; }
    friend mint ipow(mint a, lint p) {
        mint ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mint inv(const mint& a) { assert(a.val); return ipow(a, mod - 2); }
    mint& operator/=(const mint& m) { return (*this) *= inv(m); }

    friend mint operator+(mint a, const mint& b) { return a += b; }
    friend mint operator-(mint a, const mint& b) { return a -= b; }
    friend mint operator*(mint a, const mint& b) { return a *= b; }
    friend mint operator/(mint a, const mint& b) { return a /= b; }
    operator int64_t() const {return val; }
};

namespace fft{
    using real_t = double;
    using base = complex<real_t>;

    void fft(vector<base> &a, bool inv){
        int n = a.size(), j = 0;
        vector<base> roots(n/2);
        for(int i=1; i<n; i++){
            int bit = (n >> 1);
            while(j >= bit){
                j -= bit;
                bit >>= 1;
            }
            j += bit;
            if(i < j) swap(a[i], a[j]);
        }
        real_t ang = 2 * acos(real_t(-1)) / n * (inv ? -1 : 1);
        for(int i=0; i<n/2; i++){
            roots[i] = base(cos(ang * i), sin(ang * i));
        }
        /*
           XOR Convolution : set roots[*] = 1.
           OR Convolution : set roots[*] = 1, and do following:
           if (!inv) {
           a[j + k] = u + v;
           a[j + k + i/2] = u;
           } else {
           a[j + k] = v;
           a[j + k + i/2] = u - v;
           }
         */
        for(int i=2; i<=n; i<<=1){
            int step = n / i;
            for(int j=0; j<n; j+=i){
                for(int k=0; k<i/2; k++){
                    base u = a[j+k], v = a[j+k+i/2] * roots[step * k];
                    a[j+k] = u+v;
                    a[j+k+i/2] = u-v;
                }
            }
        }
        if(inv) for(int i=0; i<n; i++) a[i] /= n; // skip for OR convolution.
    }
    template<typename T>
    void ntt(vector<T> &a, bool inv){
        const int prr = 3; // primitive root
        int n = a.size(), j = 0;
        vector<T> roots(n/2);
        for(int i=1; i<n; i++){
            int bit = (n >> 1);
            while(j >= bit){
                j -= bit;
                bit >>= 1;
            }
            j += bit;
            if(i < j) swap(a[i], a[j]);
        }
        T ang = ipow(T(prr), (mod - 1) / n);
        if(inv) ang = T(1) / ang;
        for(int i=0; i<n/2; i++){
            roots[i] = (i ? (roots[i-1] * ang) : T(1));
        }
        for(int i=2; i<=n; i<<=1){
            int step = n / i;
            for(int j=0; j<n; j+=i){
                for(int k=0; k<i/2; k++){
                    T u = a[j+k], v = a[j+k+i/2] * roots[step * k];
                    a[j+k] = u+v;
                    a[j+k+i/2] = u-v;
                }
            }
        }
        if(inv){
            T rev = T(1) / T(n);
            for(int i=0; i<n; i++) a[i] *= rev;
        }
    }
    template<typename T>
    vector<T> multiply_ntt(vector<T> &v, const vector<T> &w){
        vector<T> fv(all(v)), fw(all(w));
        int n = 2;
        while(n < sz(v) + sz(w)) n <<= 1;
        fv.resize(n); fw.resize(n);
        ntt(fv, 0); ntt(fw, 0);
        for(int i=0; i<n; i++) fv[i] *= fw[i];
        ntt(fv, 1);
        vector<T> ret(n);
        for(int i=0; i<n; i++) ret[i] = fv[i];
        return ret;
    }
    template<typename T>
    vector<T> multiply(vector<T> &v, const vector<T> &w){
        vector<base> fv(all(v)), fw(all(w));
        int n = 2;
        while(n < sz(v) + sz(w)) n <<= 1;
        fv.resize(n); fw.resize(n);
        fft(fv, 0); fft(fw, 0);
        for(int i=0; i<n; i++) fv[i] *= fw[i];
        fft(fv, 1);
        vector<T> ret(n);
        for(int i=0; i<n; i++) ret[i] = (T)llround(fv[i].real());
        return ret;
    }
    template<typename T>
    vector<T> multiply_mod(vector<T> v, const vector<T> &w){
        int n = 2;
        while(n < sz(v) + sz(w)) n <<= 1;
        vector<base> v1(n), v2(n), r1(n), r2(n);
        for(int i=0; i<v.size(); i++){
            v1[i] = base(v[i] >> 15, v[i] & 32767);
        }
        for(int i=0; i<w.size(); i++){
            v2[i] = base(w[i] >> 15, w[i] & 32767);
        }
        fft(v1, 0);
        fft(v2, 0);
        for(int i=0; i<n; i++){
            int j = (i ? (n - i) : i);
            base ans1 = (v1[i] + conj(v1[j])) * base(0.5, 0);
            base ans2 = (v1[i] - conj(v1[j])) * base(0, -0.5);
            base ans3 = (v2[i] + conj(v2[j])) * base(0.5, 0);
            base ans4 = (v2[i] - conj(v2[j])) * base(0, -0.5);
            r1[i] = (ans1 * ans3) + (ans1 * ans4) * base(0, 1);
            r2[i] = (ans2 * ans3) + (ans2 * ans4) * base(0, 1);
        }
        fft(r1, 1);
        fft(r2, 1);
        vector<T> ret(n);
        for(int i=0; i<n; i++){
            T av = llround(r1[i].real());
            T bv = llround(r1[i].imag()) + llround(r2[i].real());
            T cv = llround(r2[i].imag());
            av = av << 30;
            bv = bv << 15;
            ret[i] = av + bv + cv;
        }
        return ret;
    }
    template<typename T>
    vector<T> multiply_naive(vector<T> v, const vector<T> &w){
        if(sz(v) == 0 || sz(w) == 0) return vector<T>();
        vector<T> ret(sz(v) + sz(w) - 1);
        for(int i=0; i<sz(v); i++){
            for(int j=0; j<sz(w); j++){
                ret[i + j] += v[i] * w[j];
            }
        }
        return ret;
    }
}

template<typename T>
struct poly {
    vector<T> a;

    void normalize() { // get rid of leading zeroes
        while(!a.empty() && a.back() == T(0)) {
            a.pop_back();
        }
    }

    poly(){}
    poly(T a0){ a = {a0}; normalize(); }
    poly(vector<T> t) : a(t){ normalize(); }

    int deg() const{ return sz(a) - 1; } // -1 if empty
    T lead() const{ return sz(a) ? a.back() : T(0); }

    T operator [](int idx) const {
        return idx >= (int)a.size() || idx < 0 ? T(0) : a[idx];
    }

    T& coef(size_t idx) { // mutable reference at coefficient
        return a[idx];
    }

    poly reversed() const{
        vector<T> b = a;
        reverse(all(b));
        return poly(b);
    }
    poly trim(int n) const{
        n = min(n, sz(a));
        vector<T> b(a.begin(), a.begin() + n);
        return poly(b);
    }

    poly operator *= (const T &x) {
        for(auto &it: a) {
            it *= x;
        }
        normalize();
        return *this;
    }
    poly operator /= (const T &x) {
        return *this *= (T(1)/ T(x));
    }
    poly operator * (const T &x) const {return poly(*this) *= x;}
    poly operator / (const T &x) const {return poly(*this) /= x;}

    poly operator+=(const poly &p){
        a.resize(max(sz(a), sz(p.a)));
        for(int i=0; i<sz(p.a); i++){
            a[i] += p.a[i];
        }
        normalize();
        return *this;
    }
    poly operator-=(const poly &p){
        a.resize(max(sz(a), sz(p.a)));
        for(int i=0; i<sz(p.a); i++){
            a[i] -= p.a[i];
        }
        normalize();
        return *this;
    }
    poly operator*=(const poly &p){
        *this = poly(fft::multiply_mod(a, p.a));
        normalize();
        return *this;
    }
    poly inv(int n){
        poly q(T(1) / a[0]);
        for(int i=1; i<n; i<<=1){
            poly p = poly(2) - q * trim(i * 2);
            q = (p * q).trim(i * 2);
        }
        return q.trim(n);
    }
    pair<poly, poly> divmod_slow(const poly &b) const { // when divisor or quotient is small
        vector<T> A(a);
        vector<T> res;
        while(A.size() >= b.a.size()) {
            res.push_back(A.back() / b.a.back());
            if(res.back() != T(0)) {
                for(size_t i = 0; i < b.a.size(); i++) {
                    A[A.size() - i - 1] -= res.back() * b.a[b.a.size() - i - 1];
                }
            }
            A.pop_back();
        }
        reverse(all(res));
        return {res, A};
    }

    poly operator/=(const poly &b){
        if(deg() < b.deg()) return *this = poly();
        if(min(deg(), b.deg()) < 256) return *this = divmod_slow(b).first;
        int k = deg() - b.deg() + 1;
        poly ra = reversed().trim(k);
        poly rb = b.reversed().trim(k).inv(k);
        *this = (ra * rb).trim(k);
        while(sz(a) < k) a.push_back(T(0));
        reverse(all(a));
        normalize();
        return *this;
    }
    poly operator%=(const poly &b){
        if(deg() < b.deg()) return *this;
        if(min(deg(), b.deg()) < 256) return *this = divmod_slow(b).second;
        poly foo = poly(a); foo /= b; foo *= b;
        *this = poly(*this) -= foo;
        normalize();
        return *this;
    }

    poly operator+(const poly &p)const{ return poly(*this) += p; }
    poly operator-(const poly &p)const{ return poly(*this) -= p; }
    poly operator*(const poly &p)const{ return poly(*this) *= p; }
    poly operator/(const poly &p)const{ return poly(*this) /= p; }
    poly operator%(const poly &p)const{ return poly(*this) %= p; }

    poly deriv() { // calculate derivative
        vector<T> res;
        for(int i = 1; i <= deg(); i++) {
            res.push_back(T(i) * a[i]);
        }
        return res;
    }
    poly integr() { // calculate integral with C = 0
        vector<T> res = {0};
        for(int i = 0; i <= deg(); i++) {
            res.push_back(a[i] / T(i + 1));
        }
        return res;
    }
    poly ln(int n){
        assert(sz(a) > 0 && a[0] == T(1));
        return (deriv() * inv(n)).integr().trim(n);
    }
    poly exp(int n){
        if(sz(a) == 0){
            return poly({T(1)});
        }
        assert(sz(a) > 0 && a[0] == T(0));
        poly q(1);
        for(int i=1; i<n; i<<=1){
            poly p = poly(1) + trim(2 * i) - q.ln(2 * i);
            q = (q * p).trim(2 * i);
        }
        return q.trim(n);
    }
    poly power(int n, int k){
        if(sz(a) == 0) return poly();
        if(k == 0) return poly(T(1)).trim(n);
        if(k == 1) return trim(n);
        int ptr = 0;
        while(ptr < sz(a) && a[ptr] == T(0)) ptr++;
        if(1ll * ptr * k >= n) return poly();
        n -= ptr * k;
        poly p(vector<T>(a.begin() + ptr, a.end()));
        T coeff = a[ptr];
        p /= coeff;
        p = p.ln(n);
        p *= k;
        p = p.exp(n);
        p *= ipow(coeff, k);
        vector<T> q(ptr * k, T(0));
        for(int i=0; i<=p.deg(); i++) q.push_back(p[i]);
        return poly(q);
    }
    poly root(int n, int k = 2){
        // NOT TESTED in K > 2
        assert(sz(a) > 0 && a[0] == T(1) && k >= 2);
        poly q(1);
        for(int i=1; i<n; i<<=1){
            if(k == 2) q += trim(2 * i) * q.inv(2 * i);
            else q = q * T(k - 1) + trim(2 * i) * power(q.inv(2 * i), k - 1, 2 * i);
            q = q.trim(2 * i) / T(k);
        }
        return q.trim(n);
    }
};

// polynomial taylor shift
// return f(x + a)
poly<mint> taylor_shift(poly<mint>& f, mint a) {
    poly<mint> ff = f;
    reverse(ff.a.begin(), ff.a.end());
    vector<mint> gg_vec(ff.a.size(), mint(1));
    poly<mint> gg(gg_vec);
    mint fac = 1;
    for (int i = 1; i < ff.a.size(); i++) {
        ff.a[ff.a.size() - i - 1] *= fac;
        fac *= mint(i + 1);
    }
    for (int i = 1; i < ff.a.size(); i++) {
        gg.a[i] = gg.a[i - 1] * a;
        gg.a[i] /= mint(i);
    }
    poly<mint> res = (ff * gg).trim(ff.a.size());
    res.a.resize(ff.a.size());
    reverse(res.a.begin(), res.a.end());
    
    mint inv_fac = mint(1) / fac;
    for (int i = ff.a.size() - 1; i >= 0; i--) {
        inv_fac *= mint(i + 1);
        res.a[i] *= inv_fac;
    }
    res.a.resize(ff.a.size());
    return res;
}

// multipoint evaluation
// return {f(x_0), f(x_1), ..., f(x_{n-1})}
vector<mint> multipoint_evaluation(poly<mint>& f, vector<mint>& x) {
    int n = x.size();
    int seg_n = 1;
    while (seg_n < n) seg_n <<= 1;
    // stores \prod_{l \leq i < r} (x - x_i)
    vector<poly<mint>> mul_seg(2 * seg_n);
    vector<poly<mint>> res_seg(2 * seg_n);
    for (int i = 0; i < n; i++) {
        mul_seg[seg_n + i] = poly<mint>({-x[i], 1});
    }
    for (int i = n; i < seg_n; i++) {
        mul_seg[seg_n + i] = poly<mint>(1);
    }
    for (int i = seg_n - 1; i >= 1; i--) {
        if (mul_seg[i * 2 + 1].deg() == 0) {
            mul_seg[i] = mul_seg[i * 2];
        }
        else {
            mul_seg[i] = mul_seg[i * 2] * mul_seg[i * 2 + 1];
        }
    }
    res_seg[1] = f % mul_seg[1];
    for (int i = 1; i < seg_n; i++) {
        res_seg[i * 2] = res_seg[i] % mul_seg[i * 2];
        res_seg[i * 2 + 1] = res_seg[i] % mul_seg[i * 2 + 1];
    }
    vector<mint> res(n);
    for (int i = 0; i < n; i++) {
        if (res_seg[seg_n + i].deg() == -1) {
            res[i] = mint(0);
        }
        else {
            res[i] = res_seg[seg_n + i].a[0];
        }
    }
    return res;
}

// calculate product of multiple polynomials
poly<mint> multiply_polynomials(vector<poly<mint>>& polynomials) {
    int n = polynomials.size();
    int seg_n = 1;
    while (seg_n < n) seg_n <<= 1;
    vector<poly<mint>> seg(2 * seg_n);
    for (int i = 0; i < n; i++) {
        seg[seg_n + i] = polynomials[i];
    }
    for (int i = n; i < seg_n; i++) {
        seg[seg_n + i] = poly<mint>(1);
    }
    for (int i = seg_n - 1; i >= 1; i--) {
        if (seg[i * 2 + 1].deg() == 0) {
            seg[i] = seg[i * 2];
        }
        else {
            seg[i] = seg[i * 2] * seg[i * 2 + 1];
        }
    }
    return seg[1];
}

int N;

vector<mint> points, dual_points;

mint factorial[131073];
mint inv_factorial[131073];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    factorial[0] = 1;
    for (int i = 1; i <= 131072; i++) {
        factorial[i] = factorial[i - 1] * mint(i);
    }
    inv_factorial[131072] = mint(1) / factorial[131072];
    for (int i = 131071; i >= 0; i--) {
        inv_factorial[i] = inv_factorial[i + 1] * mint(i + 1);
    }

    cin >> N;
    points.resize(N);
    dual_points.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> points[i].val;
    }

    int rook_cnt = 1;
    while (rook_cnt <= N) {
        if (rook_cnt > points[N - rook_cnt].val) {
            break;
        }
        ++rook_cnt;
    }
    --rook_cnt;
    cout << rook_cnt << " ";

    int curr_idx = N - 1;
    for (int curr_width = N; curr_width > 0; --curr_width) {
        while (curr_idx >= 0) {
            if (points[curr_idx].val < curr_width) {
                break;
            }
            --curr_idx;
        }
        dual_points[curr_width - 1] = N - 1 - curr_idx;
    }
    reverse(points.begin(), points.end());

    vector<poly<mint>> polynomials(rook_cnt), dual_polynomials(rook_cnt);
    for (int i = 0; i < rook_cnt; ++i) {
        polynomials[i] = poly<mint>({points[i], -1});
        dual_polynomials[i] = poly<mint>({dual_points[i], -1});
    }
    poly<mint> prod = multiply_polynomials(polynomials);
    poly<mint> dual_prod = multiply_polynomials(dual_polynomials);

    mint ans = mint(0);

    int t = (rook_cnt == N ? 0 : points[rook_cnt].val);
    vector<mint> points_t(t + 1);
    for (int i = 0; i <= t; ++i) {
        points_t[i] = mint(i);
    }
    vector<mint> values = multipoint_evaluation(prod, points_t);
    for (int i = 0; i <= t; ++i) {
        mint val = values[i];
        if (i % 2) {
            val = -val;
        }
        val *= factorial[t];
        val *= inv_factorial[i];
        val *= inv_factorial[t - i];
        ans += val;
    }

    int dual_t = (rook_cnt == N ? 0 : dual_points[rook_cnt].val);
    vector<mint> dual_points_t(dual_t + 1);
    for (int i = 0; i <= dual_t; ++i) {
        dual_points_t[i] = mint(i);
    }
    vector<mint> dual_values = multipoint_evaluation(dual_prod, dual_points_t);
    for (int i = 0; i <= dual_t; ++i) {
        mint val = dual_values[i];
        if (i % 2) {
            val = -val;
        }
        val *= factorial[dual_t];
        val *= inv_factorial[i];
        val *= inv_factorial[dual_t - i];
        ans += val;
    }

    ans -= factorial[rook_cnt];

    cout << ans << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 2 3

output:

2 6

result:

ok 2 number(s): "2 6"

Test #2:

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

input:

1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

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

input:

2
1 1

output:

1 2

result:

ok 2 number(s): "1 2"

Test #4:

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

input:

2
2 2

output:

2 6

result:

ok 2 number(s): "2 6"

Test #5:

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

input:

3
1 1 1

output:

1 3

result:

ok 2 number(s): "1 3"

Test #6:

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

input:

3
2 2 2

output:

2 9

result:

ok 2 number(s): "2 9"

Test #7:

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

input:

3
3 3 3

output:

3 48

result:

ok 2 number(s): "3 48"

Test #8:

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

input:

5
1 1 3 3 4

output:

3 47

result:

ok 2 number(s): "3 47"

Test #9:

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

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: 4752kb

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: 4884kb

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: 4ms
memory: 5032kb

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: 23ms
memory: 5816kb

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: 52ms
memory: 6464kb

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: 79ms
memory: 6520kb

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: 120ms
memory: 7632kb

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: 31ms
memory: 6952kb

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: 100ms
memory: 7868kb

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: 130ms
memory: 7868kb

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: 139ms
memory: 7804kb

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: 134ms
memory: 7732kb

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: 103ms
memory: 6968kb

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: 103ms
memory: 6800kb

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: 102ms
memory: 6724kb

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: 81ms
memory: 6708kb

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: 5536kb

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: 3ms
memory: 4892kb

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: 3ms
memory: 4848kb

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: 0ms
memory: 4828kb

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: 0ms
memory: 4848kb

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: 4904kb

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: 4832kb

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: 5040kb

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: 5040kb

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: 63ms
memory: 6312kb

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: 136ms
memory: 7912kb

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: 141ms
memory: 7820kb

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: 135ms
memory: 7812kb

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: 127ms
memory: 7848kb

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: 26ms
memory: 6836kb

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: 6800kb

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: 177ms
memory: 7860kb

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: 660ms
memory: 16356kb

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: 1645ms
memory: 28644kb

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: 2209ms
memory: 32100kb

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: 2942ms
memory: 39940kb

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: 3ms
memory: 5232kb

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: 6ms
memory: 5164kb

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: 0ms
memory: 5208kb

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: 3ms
memory: 5232kb

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: 7ms
memory: 5304kb

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: 5ms
memory: 5364kb

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: 13ms
memory: 5928kb

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: 6252kb

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: 161ms
memory: 8436kb

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: 425ms
memory: 11880kb

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: 1475ms
memory: 28932kb

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: 2647ms
memory: 34564kb

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: 3768ms
memory: 55156kb

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: 5008ms
memory: 59616kb

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: 5517ms
memory: 61540kb

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: 6069ms
memory: 64800kb

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: 6305ms
memory: 66696kb

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: 6297ms
memory: 66816kb

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: 6314ms
memory: 66896kb

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: 6207ms
memory: 65640kb

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: 6026ms
memory: 66996kb

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: 5676ms
memory: 63900kb

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: 2566ms
memory: 51424kb

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: 1093ms
memory: 60752kb

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: 996ms
memory: 51620kb

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: 3634ms
memory: 64888kb

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: 3668ms
memory: 64832kb

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: 6345ms
memory: 67056kb

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: 6422ms
memory: 73056kb

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"