QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#443303 | #8526. Polygon II | ucup-team087# | AC ✓ | 2588ms | 4324kb | C++14 | 15.2kb | 2024-06-15 15:05:59 | 2024-06-15 15:06:02 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
static constexpr unsigned M = M_;
unsigned x;
constexpr ModInt() : x(0U) {}
constexpr ModInt(unsigned x_) : x(x_ % M) {}
constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
ModInt pow(long long e) const {
if (e < 0) return inv().pow(-e);
ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
}
ModInt inv() const {
unsigned a = M, b = x; int y = 0, z = 1;
for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
assert(a == 1U); return ModInt(y);
}
ModInt operator+() const { return *this; }
ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
explicit operator bool() const { return x; }
bool operator==(const ModInt &a) const { return (x == a.x); }
bool operator!=(const ModInt &a) const { return (x != a.x); }
friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// M: prime, G: primitive root, 2^K | M - 1
template <unsigned M_, unsigned G_, int K_> struct Fft {
static_assert(2U <= M_, "Fft: 2 <= M must hold.");
static_assert(M_ < 1U << 30, "Fft: M < 2^30 must hold.");
static_assert(1 <= K_, "Fft: 1 <= K must hold.");
static_assert(K_ < 30, "Fft: K < 30 must hold.");
static_assert(!((M_ - 1U) & ((1U << K_) - 1U)), "Fft: 2^K | M - 1 must hold.");
static constexpr unsigned M = M_;
static constexpr unsigned M2 = 2U * M_;
static constexpr unsigned G = G_;
static constexpr int K = K_;
ModInt<M> FFT_ROOTS[K + 1], INV_FFT_ROOTS[K + 1];
ModInt<M> FFT_RATIOS[K], INV_FFT_RATIOS[K];
Fft() {
const ModInt<M> g(G);
for (int k = 0; k <= K; ++k) {
FFT_ROOTS[k] = g.pow((M - 1U) >> k);
INV_FFT_ROOTS[k] = FFT_ROOTS[k].inv();
}
for (int k = 0; k <= K - 2; ++k) {
FFT_RATIOS[k] = -g.pow(3U * ((M - 1U) >> (k + 2)));
INV_FFT_RATIOS[k] = FFT_RATIOS[k].inv();
}
assert(FFT_ROOTS[1] == M - 1U);
}
// as[rev(i)] <- \sum_j \zeta^(ij) as[j]
void fft(ModInt<M> *as, int n) const {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
int m = n;
if (m >>= 1) {
for (int i = 0; i < m; ++i) {
const unsigned x = as[i + m].x; // < M
as[i + m].x = as[i].x + M - x; // < 2 M
as[i].x += x; // < 2 M
}
}
if (m >>= 1) {
ModInt<M> prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < M
as[i + m].x = as[i].x + M - x; // < 3 M
as[i].x += x; // < 3 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
for (; m; ) {
if (m >>= 1) {
ModInt<M> prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < M
as[i + m].x = as[i].x + M - x; // < 4 M
as[i].x += x; // < 4 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m >>= 1) {
ModInt<M> prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < M
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i + m].x = as[i].x + M - x; // < 3 M
as[i].x += x; // < 3 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
}
for (int i = 0; i < n; ++i) {
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i].x = (as[i].x >= M) ? (as[i].x - M) : as[i].x; // < M
}
}
// as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
void invFft(ModInt<M> *as, int n) const {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
int m = 1;
if (m < n >> 1) {
ModInt<M> prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned long long y = as[i].x + M - as[i + m].x; // < 2 M
as[i].x += as[i + m].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
m <<= 1;
}
for (; m < n >> 1; m <<= 1) {
ModInt<M> prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + (m >> 1); ++i) {
const unsigned long long y = as[i].x + M2 - as[i + m].x; // < 4 M
as[i].x += as[i + m].x; // < 4 M
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
const unsigned long long y = as[i].x + M - as[i + m].x; // < 2 M
as[i].x += as[i + m].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m < n) {
for (int i = 0; i < m; ++i) {
const unsigned y = as[i].x + M2 - as[i + m].x; // < 4 M
as[i].x += as[i + m].x; // < 4 M
as[i + m].x = y; // < 4 M
}
}
const ModInt<M> invN = ModInt<M>(n).inv();
for (int i = 0; i < n; ++i) {
as[i] *= invN;
}
}
void fft(vector<ModInt<M>> &as) const {
fft(as.data(), as.size());
}
void invFft(vector<ModInt<M>> &as) const {
invFft(as.data(), as.size());
}
vector<ModInt<M>> convolve(vector<ModInt<M>> as, vector<ModInt<M>> bs) const {
if (as.empty() || bs.empty()) return {};
const int len = as.size() + bs.size() - 1;
int n = 1;
for (; n < len; n <<= 1) {}
as.resize(n); fft(as);
bs.resize(n); fft(bs);
for (int i = 0; i < n; ++i) as[i] *= bs[i];
invFft(as);
as.resize(len);
return as;
}
vector<ModInt<M>> square(vector<ModInt<M>> as) const {
if (as.empty()) return {};
const int len = as.size() + as.size() - 1;
int n = 1;
for (; n < len; n <<= 1) {}
as.resize(n); fft(as);
for (int i = 0; i < n; ++i) as[i] *= as[i];
invFft(as);
as.resize(len);
return as;
}
};
// M0 M1 M2 = 789204840662082423367925761 (> 7.892 * 10^26, > 2^89)
// M0 M3 M4 M5 M6 = 797766583174034668024539679147517452591562753 (> 7.977 * 10^44, > 2^149)
const Fft<998244353U, 3U, 23> FFT0;
const Fft<897581057U, 3U, 23> FFT1;
const Fft<880803841U, 26U, 23> FFT2;
const Fft<985661441U, 3U, 22> FFT3;
const Fft<943718401U, 7U, 22> FFT4;
const Fft<935329793U, 3U, 22> FFT5;
const Fft<918552577U, 5U, 22> FFT6;
// T = unsigned, unsigned long long, ModInt<M>
template <class T, unsigned M0, unsigned M1, unsigned M2>
T garner(ModInt<M0> a0, ModInt<M1> a1, ModInt<M2> a2) {
static const ModInt<M1> INV_M0_M1 = ModInt<M1>(M0).inv();
static const ModInt<M2> INV_M0M1_M2 = (ModInt<M2>(M0) * M1).inv();
const ModInt<M1> b1 = INV_M0_M1 * (a1 - a0.x);
const ModInt<M2> b2 = INV_M0M1_M2 * (a2 - (ModInt<M2>(b1.x) * M0 + a0.x));
return (T(b2.x) * M1 + b1.x) * M0 + a0.x;
}
template <class T, unsigned M0, unsigned M1, unsigned M2, unsigned M3, unsigned M4>
T garner(ModInt<M0> a0, ModInt<M1> a1, ModInt<M2> a2, ModInt<M3> a3, ModInt<M4> a4) {
static const ModInt<M1> INV_M0_M1 = ModInt<M1>(M0).inv();
static const ModInt<M2> INV_M0M1_M2 = (ModInt<M2>(M0) * M1).inv();
static const ModInt<M3> INV_M0M1M2_M3 = (ModInt<M3>(M0) * M1 * M2).inv();
static const ModInt<M4> INV_M0M1M2M3_M4 = (ModInt<M4>(M0) * M1 * M2 * M3).inv();
const ModInt<M1> b1 = INV_M0_M1 * (a1 - a0.x);
const ModInt<M2> b2 = INV_M0M1_M2 * (a2 - (ModInt<M2>(b1.x) * M0 + a0.x));
const ModInt<M3> b3 = INV_M0M1M2_M3 * (a3 - ((ModInt<M3>(b2.x) * M1 + b1.x) * M0 + a0.x));
const ModInt<M4> b4 = INV_M0M1M2M3_M4 * (a4 - (((ModInt<M4>(b3.x) * M2 + b2.x) * M1 + b1.x) * M0 + a0.x));
return (((T(b4.x) * M3 + b3.x) * M2 + b2.x) * M1 + b1.x) * M0 + a0.x;
}
constexpr unsigned MO = 1000000007;
using Mint = ModInt<MO>;
vector<Mint> convolve(const vector<Mint> &as, const vector<Mint> &bs) {
static constexpr unsigned M0 = decltype(FFT0)::M;
static constexpr unsigned M1 = decltype(FFT1)::M;
static constexpr unsigned M2 = decltype(FFT2)::M;
if (as.empty() || bs.empty()) return {};
const int asLen = as.size(), bsLen = bs.size();
vector<ModInt<M0>> as0(asLen), bs0(bsLen);
for (int i = 0; i < asLen; ++i) as0[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs0[i] = bs[i].x;
const vector<ModInt<M0>> cs0 = FFT0.convolve(as0, bs0);
vector<ModInt<M1>> as1(asLen), bs1(bsLen);
for (int i = 0; i < asLen; ++i) as1[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs1[i] = bs[i].x;
const vector<ModInt<M1>> cs1 = FFT1.convolve(as1, bs1);
vector<ModInt<M2>> as2(asLen), bs2(bsLen);
for (int i = 0; i < asLen; ++i) as2[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs2[i] = bs[i].x;
const vector<ModInt<M2>> cs2 = FFT2.convolve(as2, bs2);
vector<Mint> cs(asLen + bsLen - 1);
for (int i = 0; i < asLen + bsLen - 1; ++i) {
cs[i] = garner<Mint>(cs0[i], cs1[i], cs2[i]);
}
return cs;
}
constexpr int LIM_INV = 2010;
Mint inv[LIM_INV], fac[LIM_INV], invFac[LIM_INV];
void prepare() {
inv[1] = 1;
for (int i = 2; i < LIM_INV; ++i) {
inv[i] = -((Mint::M / i) * inv[Mint::M % i]);
}
fac[0] = invFac[0] = 1;
for (int i = 1; i < LIM_INV; ++i) {
fac[i] = fac[i - 1] * i;
invFac[i] = invFac[i - 1] * inv[i];
}
}
Mint binom(Int n, Int k) {
if (n < 0) {
if (k >= 0) {
return ((k & 1) ? -1 : +1) * binom(-n + k - 1, k);
} else if (n - k >= 0) {
return (((n - k) & 1) ? -1 : +1) * binom(-k - 1, n - k);
} else {
return 0;
}
} else {
if (0 <= k && k <= n) {
assert(n < LIM_INV);
return fac[n] * invFac[k] * invFac[n - k];
} else {
return 0;
}
}
}
int N;
vector<int> A;
int maxA;
vector<int> freq, suf;
// [x^[l,r]] (1 + x)^* (1 + x^2)^* ...
vector<Mint> solve(int p, int a, Int l, Int r) {
assert(l <= r);
if (a >= maxA) {
vector<Mint> ret(r - l + 1);
for (Int m = l; m <= r; ++m) {
ret[m - l] = (a ? (m >= 0) : (m == 0)) ? 1 : 0;
}
return ret;
}
const int f = p + suf[a];
Int ll = l - f, rr = r;
if (ll & 1) ++ll;
if (rr & 1) --rr;
ll /= 2;
rr /= 2;
// cerr<<"HELP f="<<f<<"; "<<l<<" "<<r<<" -> "<<ll<<" "<<rr<<endl;
auto res = solve(p, a + 1, ll, rr);
const int resLen = res.size();
vector<Mint> bs(f + 1, 0), cs(resLen * 2 - 1, 0);
for (int j = 0; j <= f; ++j) bs[j] = binom(f, j);
for (int j = 0; j < resLen; ++j) cs[j * 2] = res[j];
auto ret = convolve(bs, cs);
ret.erase(ret.begin(), ret.begin() + (l - ll * 2));
ret.resize(r - l + 1);
// cerr<<"[solve] "<<p<<" "<<a<<" "<<l<<" "<<r<<" = "<<ret<<endl;
return ret;
}
int main() {
prepare();
for (; ~scanf("%d", &N); ) {
A.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%d", &A[i]);
}
maxA = *max_element(A.begin(), A.end());
freq.assign(maxA + 1, 0);
for (int i = 0; i < N; ++i) {
++freq[A[i]];
}
suf = freq;
for (int a = maxA; --a >= 0; ) {
suf[a] += suf[a + 1];
}
suf.erase(suf.begin());
cerr<<"suf = "<<suf<<endl;
vector<Mint> pw(N + 1);
for (int j = 0; j <= N; ++j) pw[j] = Mint(j).pow(N);
// [0, 1)^N
vector<Mint> euler(N + 1, 0);
for (int k = 1; k <= N; ++k) {
for (int j = 0; j <= k; ++j) {
euler[k] += binom(N + 1, j) * (j&1?-1:+1) * pw[k - j];
}
}
for (int k = 1; k <= N; ++k) euler[k] += euler[k - 1];
// cerr<<"euler = "<<euler<<endl;
Mint ans = 0;
for (int a = 0; a <= maxA; ++a) {
Mint here = 0;
{
const auto res = solve(1, 0, (1LL << a) - N, (1LL << a) - N);
// cerr<<__LINE__<<": res = "<<res<<endl;
here += res[0] * euler[N];
}
{
const auto res = solve(0, 0, (1LL << a) - N + 1, (1LL << a) - 1);
// cerr<<__LINE__<<": res = "<<res<<endl;
for (int k = 1; k < N; ++k) {
here += res[N - 1 - k] * euler[k];
}
}
// cerr<<"a = "<<a<<": "<<here<<endl;
ans += freq[a] * here;
}
cerr<<"ans = "<<ans<<endl;
ans *= invFac[N];
for (int i = 0; i < N; ++i) {
ans *= Mint(2).pow(-A[i]);
}
ans = 1 - ans;
printf("%u\n", ans.x);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
3 0 2 0
output:
166666668
result:
ok 1 number(s): "166666668"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
3 0 0 0
output:
500000004
result:
ok 1 number(s): "500000004"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
3 5 6 7
output:
208333335
result:
ok 1 number(s): "208333335"
Test #4:
score: 0
Accepted
time: 5ms
memory: 4124kb
input:
3 0 25 50
output:
889268532
result:
ok 1 number(s): "889268532"
Test #5:
score: 0
Accepted
time: 10ms
memory: 3868kb
input:
10 39 11 25 1 12 44 10 46 27 15
output:
913863330
result:
ok 1 number(s): "913863330"
Test #6:
score: 0
Accepted
time: 74ms
memory: 3960kb
input:
57 43 22 3 16 7 5 24 32 25 16 41 28 24 30 28 10 32 48 41 43 34 37 48 34 3 9 21 41 49 25 2 0 36 45 34 33 45 9 42 29 43 9 38 34 44 33 44 6 46 39 22 36 40 37 19 34 3
output:
400729664
result:
ok 1 number(s): "400729664"
Test #7:
score: 0
Accepted
time: 104ms
memory: 3944kb
input:
100 44 32 6 6 6 44 12 32 6 9 23 12 14 23 12 14 23 49 6 14 32 23 49 9 32 24 23 6 32 6 49 23 12 44 24 9 14 6 24 44 24 23 44 44 49 32 49 12 49 49 24 49 12 23 3 14 6 3 3 6 12 3 49 24 49 24 24 32 23 32 49 14 3 24 49 3 32 14 44 24 49 3 32 23 49 44 44 9 23 14 49 9 3 6 44 24 3 3 12 44
output:
32585394
result:
ok 1 number(s): "32585394"
Test #8:
score: 0
Accepted
time: 234ms
memory: 4040kb
input:
1000 2 27 0 0 27 0 2 0 27 0 27 27 0 0 0 0 0 2 0 27 0 2 2 0 27 27 0 0 0 27 2 2 2 27 0 2 27 2 0 2 27 0 0 27 0 27 0 0 27 2 27 2 2 27 2 27 0 0 27 0 27 0 2 27 2 2 0 27 27 27 27 0 27 0 27 0 2 2 0 2 2 27 0 0 27 0 0 27 0 2 27 27 2 27 2 0 0 2 27 27 27 27 27 27 2 2 0 2 2 0 2 2 0 27 0 27 2 2 0 27 27 0 0 27 2 2...
output:
94588769
result:
ok 1 number(s): "94588769"
Test #9:
score: 0
Accepted
time: 1719ms
memory: 4000kb
input:
1000 40 14 47 3 32 18 3 49 22 23 32 18 23 24 18 32 23 39 32 27 49 49 22 50 50 22 23 47 14 47 50 32 22 24 49 49 18 22 18 22 50 3 32 47 40 3 39 22 24 47 32 49 49 22 32 39 14 49 39 3 32 22 24 18 39 49 24 18 40 23 23 49 39 39 18 39 27 49 14 27 27 14 18 24 39 22 40 50 18 18 18 39 39 18 23 23 22 3 49 47 2...
output:
626481946
result:
ok 1 number(s): "626481946"
Test #10:
score: 0
Accepted
time: 1294ms
memory: 4128kb
input:
1000 28 32 35 9 21 11 43 23 45 15 23 2 8 3 39 41 31 9 45 35 27 14 40 28 31 9 31 9 9 40 8 6 27 43 3 27 23 49 27 6 28 25 11 9 15 27 38 27 12 28 25 2 15 27 45 6 27 1 21 38 1 25 27 21 49 31 31 14 39 39 8 39 40 28 15 31 21 14 43 38 11 8 8 23 9 11 15 2 11 39 32 14 28 15 40 49 27 9 23 9 9 6 21 2 2 1 14 11 ...
output:
644443122
result:
ok 1 number(s): "644443122"
Test #11:
score: 0
Accepted
time: 1370ms
memory: 4048kb
input:
972 39 15 23 0 40 29 43 47 6 9 30 9 2 8 19 9 45 25 26 38 33 18 6 33 44 48 24 8 4 16 33 42 33 31 36 33 13 16 3 12 21 19 1 30 24 23 43 35 0 33 31 32 23 31 36 12 26 0 29 48 28 33 28 28 3 49 9 5 29 8 29 28 49 41 33 49 5 49 6 9 50 25 39 11 1 36 6 44 10 34 32 31 25 31 36 36 3 9 50 35 47 43 25 46 30 18 5 2...
output:
684920840
result:
ok 1 number(s): "684920840"
Test #12:
score: 0
Accepted
time: 188ms
memory: 4040kb
input:
147 34 47 42 23 46 3 41 9 15 42 21 32 24 1 19 46 29 35 38 20 2 43 36 47 19 23 20 9 6 28 48 46 45 21 19 41 31 36 50 7 11 25 0 43 38 46 21 2 26 40 32 14 45 35 47 21 13 26 26 30 3 36 35 45 36 21 21 25 2 40 35 50 23 3 16 44 40 42 6 37 36 19 20 14 30 47 13 49 47 45 26 12 15 21 42 30 19 5 21 9 28 8 3 34 4...
output:
972735235
result:
ok 1 number(s): "972735235"
Test #13:
score: 0
Accepted
time: 1373ms
memory: 4324kb
input:
1000 36 15 9 5 35 37 17 30 24 13 18 32 14 35 36 26 23 7 21 15 43 15 21 11 33 33 9 16 5 26 1 45 48 27 20 20 20 48 42 27 22 7 39 35 11 38 33 47 22 34 43 4 32 0 47 35 48 8 9 3 40 3 27 22 20 43 12 37 30 18 2 37 37 35 44 3 42 14 20 24 44 5 17 38 46 41 28 23 21 7 13 15 35 38 21 14 6 37 37 6 13 34 32 13 23...
output:
179933029
result:
ok 1 number(s): "179933029"
Test #14:
score: 0
Accepted
time: 1380ms
memory: 4084kb
input:
1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 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 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 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7...
output:
540327646
result:
ok 1 number(s): "540327646"
Test #15:
score: 0
Accepted
time: 1396ms
memory: 4080kb
input:
1000 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 46 46 46 46 46 46 46 46 46 46 46 46 46 4...
output:
169647494
result:
ok 1 number(s): "169647494"
Test #16:
score: 0
Accepted
time: 2583ms
memory: 3976kb
input:
1000 11 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 40 50 50 50 50 50 21 50 12 50 50 50 50 50 0 50 50 50 38 50 50 50 50 50 50 25 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 7 50 50 50 50 50 50 50 50 ...
output:
862643524
result:
ok 1 number(s): "862643524"
Test #17:
score: 0
Accepted
time: 2588ms
memory: 3972kb
input:
1000 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 5...
output:
819612372
result:
ok 1 number(s): "819612372"
Test #18:
score: 0
Accepted
time: 2553ms
memory: 3992kb
input:
1000 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 5...
output:
18215579
result:
ok 1 number(s): "18215579"
Test #19:
score: 0
Accepted
time: 8ms
memory: 4140kb
input:
16 0 2 24 1 23 9 14 17 28 29 25 27 15 19 11 20
output:
115090079
result:
ok 1 number(s): "115090079"
Test #20:
score: 0
Accepted
time: 4ms
memory: 3920kb
input:
1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
819612372
result:
ok 1 number(s): "819612372"
Test #21:
score: 0
Accepted
time: 5ms
memory: 3840kb
input:
18 9 4 21 5 22 6 9 16 3 14 11 2 0 12 6 3 7 21
output:
0
result:
ok 1 number(s): "0"
Extra Test:
score: 0
Extra Test Passed