QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506545 | #9125. Majority and Permutation | hos_lyric | AC ✓ | 133ms | 13336kb | C++14 | 12.7kb | 2024-08-05 19:16:30 | 2024-08-05 19:16:30 |
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; }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
constexpr unsigned MO = 998244353U;
constexpr unsigned MO2 = 2U * MO;
constexpr int FFT_MAX = 23;
using Mint = ModInt<MO>;
constexpr Mint FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 911660635U, 372528824U, 929031873U, 452798380U, 922799308U, 781712469U, 476477967U, 166035806U, 258648936U, 584193783U, 63912897U, 350007156U, 666702199U, 968855178U, 629671588U, 24514907U, 996173970U, 363395222U, 565042129U, 733596141U, 267099868U, 15311432U};
constexpr Mint INV_FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 86583718U, 509520358U, 337190230U, 87557064U, 609441965U, 135236158U, 304459705U, 685443576U, 381598368U, 335559352U, 129292727U, 358024708U, 814576206U, 708402881U, 283043518U, 3707709U, 121392023U, 704923114U, 950391366U, 428961804U, 382752275U, 469870224U};
constexpr Mint FFT_RATIOS[FFT_MAX] = {911660635U, 509520358U, 369330050U, 332049552U, 983190778U, 123842337U, 238493703U, 975955924U, 603855026U, 856644456U, 131300601U, 842657263U, 730768835U, 942482514U, 806263778U, 151565301U, 510815449U, 503497456U, 743006876U, 741047443U, 56250497U, 867605899U};
constexpr Mint INV_FFT_RATIOS[FFT_MAX] = {86583718U, 372528824U, 373294451U, 645684063U, 112220581U, 692852209U, 155456985U, 797128860U, 90816748U, 860285882U, 927414960U, 354738543U, 109331171U, 293255632U, 535113200U, 308540755U, 121186627U, 608385704U, 438932459U, 359477183U, 824071951U, 103369235U};
// as[rev(i)] <- \sum_j \zeta^(ij) as[j]
void fft(Mint *as, int n) {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
int m = n;
if (m >>= 1) {
for (int i = 0; i < m; ++i) {
const unsigned x = as[i + m].x; // < MO
as[i + m].x = as[i].x + MO - x; // < 2 MO
as[i].x += x; // < 2 MO
}
}
if (m >>= 1) {
Mint 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; // < MO
as[i + m].x = as[i].x + MO - x; // < 3 MO
as[i].x += x; // < 3 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
for (; m; ) {
if (m >>= 1) {
Mint 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; // < MO
as[i + m].x = as[i].x + MO - x; // < 4 MO
as[i].x += x; // < 4 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m >>= 1) {
Mint 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; // < MO
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i + m].x = as[i].x + MO - x; // < 3 MO
as[i].x += x; // < 3 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
}
for (int i = 0; i < n; ++i) {
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i].x = (as[i].x >= MO) ? (as[i].x - MO) : as[i].x; // < MO
}
}
// as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
void invFft(Mint *as, int n) {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
int m = 1;
if (m < n >> 1) {
Mint 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 + MO - as[i + m].x; // < 2 MO
as[i].x += as[i + m].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
m <<= 1;
}
for (; m < n >> 1; m <<= 1) {
Mint 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 + MO2 - as[i + m].x; // < 4 MO
as[i].x += as[i + m].x; // < 4 MO
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
const unsigned long long y = as[i].x + MO - as[i + m].x; // < 2 MO
as[i].x += as[i + m].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m < n) {
for (int i = 0; i < m; ++i) {
const unsigned y = as[i].x + MO2 - as[i + m].x; // < 4 MO
as[i].x += as[i + m].x; // < 4 MO
as[i + m].x = y; // < 4 MO
}
}
const Mint invN = Mint(n).inv();
for (int i = 0; i < n; ++i) {
as[i] *= invN;
}
}
void fft(vector<Mint> &as) {
fft(as.data(), as.size());
}
void invFft(vector<Mint> &as) {
invFft(as.data(), as.size());
}
vector<Mint> convolve(vector<Mint> as, vector<Mint> bs) {
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<Mint> square(vector<Mint> as) {
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;
}
////////////////////////////////////////////////////////////////////////////////
namespace exper {
int N;
string A;
int freq;
vector<int> P;
bool check(int s) {
{
int now = 0;
for (int i = 1; i <= 2*N; ++i) {
now += (s >> (i - 1) & 1);
if (A[i] == '1' && i - now <= now) return false;
}
}
{
int now = 0;
for (int i = 1; i <= 2*N; ++i) {
now += (s >> P[i - 1] & 1);
if (A[i] == '1' && i - now <= now) return false;
}
}
return true;
}
bool check() {
for (int s = 0; s < 1 << (2*N); ++s) if (__builtin_popcount(s) == N) {
if (check(s)) {
return true;
}
}
return false;
}
bool easy() {
for (int i = 0; i <= 2*N; ++i) if (A[i] == '1' && A[2*N - i] == '1') {
bool cut = true;
for (int j = 0; j < i; ++j) cut = cut && (P[j] >= 2*N - i);
if (cut) {
return false;
}
}
return true;
}
void dfs(int i, int yet) {
if (i == 2*N - 1) {
const bool chk = check();
const bool eas = easy();
if (chk != eas) {
cerr << A << " " << P << ": " << chk << " " << eas << endl;
}
assert(chk == eas);
if (chk) {
++freq;
}
} else {
for (int p = 0; p < 2*N; ++p) if (yet & 1 << p) {
for (int q = p + 1; q < 2*N; ++q) if (yet & 1 << q) {
P[i + 0] = p;
P[i + 1] = q;
dfs(i + 2, yet - (1 << p) - (1 << q));
}
}
}
}
void run() {
for (N = 1; N <= 5; ++N) {
for (int h = 0; h < 1 << N; ++h) {
A = string(2*N + 1, '.');
for (int i = 0; i < N; ++i) {
A[2*i + 1] = "01"[h >> i & 1];
}
freq = 0;
P.resize(2*N);
for (int p = 0; p < 2*N; ++p) {
P[0] = p;
dfs(1, (1 << (2*N)) - 1 - (1 << p));
}
cerr << N << " " << A << ": " << freq << endl;
}
}
}
} // exper
constexpr int LIM_INV = 400'010;
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, M;
vector<int> A;
int main() {
prepare();
// exper::run();
for (; ~scanf("%d%d", &N, &M); ) {
A.resize(M);
for (int m = 0; m < M; ++m) {
scanf("%d", &A[m]);
}
vector<int> isA(2*N + 1, 0);
for (int m = 0; m < M; ++m) {
isA[A[m]] = 1;
}
vector<int> cut(2*N + 1, 0);
for (int i = 1; i < 2*N; ++i) {
cut[i] = isA[i] & isA[2*N - i];
}
cut[0] = cut[2*N] = 1;
vector<Mint> F(2*N + 1, 0);
F[0] = -1;
for (int i = 1; i <= 2*N; ++i) {
const int w = i & -i;
vector<Mint> fs(w << 1, 0);
for (int j = i - w; j < i; ++j) fs[j - (i - w)] += F[j];
vector<Mint> coef(w << 1);
for (int j = 0; j < w << 1; ++j) coef[j] = -fac[j];
fft(fs);
fft(coef);
for (int j = 0; j < w << 1; ++j) fs[j] *= coef[j];
invFft(fs);
for (int j = i; j < i + w; ++j) if (j <= 2*N && cut[j]) F[j] += fs[j - (i - w)];
}
printf("%u\n", F[2*N].x);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 5ms
memory: 8556kb
input:
2 2 1 3
output:
14
result:
ok "14"
Test #2:
score: 0
Accepted
time: 4ms
memory: 8420kb
input:
5 4 1 3 7 9
output:
2909184
result:
ok "2909184"
Test #3:
score: 0
Accepted
time: 4ms
memory: 8744kb
input:
5 1 5
output:
3614400
result:
ok "3614400"
Test #4:
score: 0
Accepted
time: 5ms
memory: 8460kb
input:
3 1 3
output:
684
result:
ok "684"
Test #5:
score: 0
Accepted
time: 5ms
memory: 8760kb
input:
5 2 5 9
output:
3614400
result:
ok "3614400"
Test #6:
score: 0
Accepted
time: 105ms
memory: 12704kb
input:
96685 10195 21 27 35 53 63 81 89 117 119 125 131 135 141 157 181 201 225 229 269 275 287 293 321 325 361 363 379 403 409 429 435 441 491 501 505 543 569 609 611 669 711 717 725 727 731 759 769 785 793 797 809 821 863 899 903 911 929 937 961 997 1051 1073 1077 1123 1157 1179 1235 1251 1275 1317 1319 ...
output:
95571712
result:
ok "95571712"
Test #7:
score: 0
Accepted
time: 78ms
memory: 10940kb
input:
64166 56097 3 9 11 13 15 17 19 21 25 27 29 31 33 35 37 39 41 43 45 47 49 51 55 57 59 61 63 65 67 69 71 73 75 77 79 85 87 89 91 93 95 97 101 105 107 111 113 115 117 119 121 123 125 127 131 133 137 141 143 145 149 153 155 159 161 163 167 169 171 173 175 177 181 183 185 187 189 191 195 197 199 201 205 ...
output:
228890492
result:
ok "228890492"
Test #8:
score: 0
Accepted
time: 122ms
memory: 13040kb
input:
98805 64583 1 3 5 7 9 13 15 17 19 21 27 33 35 39 41 43 45 47 49 53 55 57 59 61 65 67 71 73 75 77 79 81 83 85 89 91 95 97 103 107 109 121 123 127 129 135 137 139 141 143 145 149 151 153 155 157 159 161 163 167 171 173 175 177 179 181 183 185 187 189 191 197 199 203 205 207 213 215 219 221 223 225 227...
output:
184329625
result:
ok "184329625"
Test #9:
score: 0
Accepted
time: 94ms
memory: 12108kb
input:
72245 14521 5 35 37 43 75 77 97 129 155 171 173 175 179 183 209 213 219 225 227 229 241 255 257 263 271 295 297 305 307 315 321 323 335 351 361 363 369 379 389 391 395 433 435 439 443 449 451 455 463 483 497 523 531 537 557 559 567 573 589 595 609 613 633 641 643 651 655 657 669 695 701 721 793 803 ...
output:
61878119
result:
ok "61878119"
Test #10:
score: 0
Accepted
time: 75ms
memory: 10864kb
input:
63266 62348 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 127 129 131 133 135 137 139 141 143 145 149 151 153 155 157 159 161 163 165 167 169 171 173 175 17...
output:
265087059
result:
ok "265087059"
Test #11:
score: 0
Accepted
time: 122ms
memory: 12996kb
input:
96192 60042 1 3 5 7 9 13 17 21 31 33 39 41 45 47 51 53 55 57 61 63 65 67 69 75 79 81 83 85 87 89 91 95 99 101 103 105 109 111 115 131 133 135 137 141 151 153 155 157 161 165 169 173 175 177 181 183 189 193 199 205 207 209 215 217 219 221 225 227 229 231 239 243 245 247 249 251 257 263 265 273 275 27...
output:
750054525
result:
ok "750054525"
Test #12:
score: 0
Accepted
time: 106ms
memory: 12964kb
input:
96428 60349 1 3 7 9 13 19 21 23 25 27 29 37 39 41 43 45 49 51 53 55 61 63 67 69 73 75 77 81 85 87 89 91 93 95 97 99 101 111 113 117 123 125 127 129 131 135 137 139 141 149 151 155 157 161 169 171 173 175 177 179 185 189 193 197 209 211 213 219 223 225 229 231 233 235 237 239 243 247 251 253 259 263 ...
output:
214089880
result:
ok "214089880"
Test #13:
score: 0
Accepted
time: 119ms
memory: 12868kb
input:
92301 57523 3 7 9 13 15 17 19 21 27 29 31 33 45 47 53 61 63 67 71 73 75 77 79 81 83 85 87 91 93 99 101 107 109 111 113 115 117 121 125 127 129 133 135 137 139 145 147 149 153 155 159 161 165 167 171 173 175 177 183 185 189 191 193 195 197 199 205 207 211 213 215 219 221 223 225 231 235 237 239 241 2...
output:
698581206
result:
ok "698581206"
Test #14:
score: 0
Accepted
time: 115ms
memory: 12788kb
input:
92162 57420 5 7 9 15 23 25 27 29 31 35 37 39 43 45 49 51 53 57 63 65 67 69 73 77 81 83 85 87 89 99 101 103 107 109 115 117 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 153 157 159 161 167 175 177 185 189 191 197 199 201 203 219 221 223 229 231 235 239 241 243 247 251 257 259 267 275 2...
output:
779052124
result:
ok "779052124"
Test #15:
score: 0
Accepted
time: 113ms
memory: 12796kb
input:
95309 59643 1 7 9 11 15 17 23 25 29 33 35 37 45 47 49 51 53 55 59 61 63 65 67 69 71 79 81 83 85 87 89 93 95 97 103 105 107 111 113 115 117 119 121 123 127 129 131 133 135 139 141 143 147 149 159 161 163 167 169 173 179 181 183 189 193 197 199 203 207 209 211 213 215 217 223 227 229 231 237 239 241 2...
output:
895352747
result:
ok "895352747"
Test #16:
score: 0
Accepted
time: 118ms
memory: 12836kb
input:
97003 25153 11 19 27 31 53 71 75 81 85 95 97 113 129 131 139 145 159 163 171 175 193 209 211 213 217 227 237 239 241 249 253 271 275 279 295 301 309 329 331 343 351 359 361 375 379 383 389 395 401 403 413 415 425 433 441 447 451 455 473 475 495 505 521 533 535 537 539 543 559 603 605 609 611 615 619...
output:
945539005
result:
ok "945539005"
Test #17:
score: 0
Accepted
time: 116ms
memory: 12792kb
input:
99075 39136 3 5 7 15 17 19 21 29 31 33 41 51 53 55 57 59 61 65 73 81 89 91 97 101 115 119 121 123 127 133 135 149 155 157 171 175 183 185 187 189 191 199 215 225 227 229 231 237 239 241 247 257 267 269 271 273 281 283 295 299 315 323 333 337 339 343 349 351 367 377 395 397 399 407 411 413 423 427 43...
output:
432766313
result:
ok "432766313"
Test #18:
score: 0
Accepted
time: 114ms
memory: 12620kb
input:
92159 26615 5 27 33 37 49 53 65 67 69 71 73 77 93 95 107 115 143 147 155 161 163 173 175 179 183 185 203 221 225 235 241 245 253 257 271 273 291 301 305 307 317 327 337 339 347 351 353 363 375 377 379 389 397 401 405 409 419 421 437 441 443 447 453 465 477 489 491 497 505 531 547 557 559 563 571 583...
output:
232913447
result:
ok "232913447"
Test #19:
score: 0
Accepted
time: 119ms
memory: 12796kb
input:
93053 56499 1 5 9 11 13 17 19 23 25 29 31 37 39 45 47 49 51 55 59 65 67 69 71 75 79 83 91 99 103 105 107 109 111 113 115 117 121 123 125 127 129 131 133 135 137 139 141 145 151 157 159 161 165 167 169 171 175 177 179 181 183 185 187 191 193 195 197 199 201 205 207 209 211 215 217 221 223 227 233 235...
output:
694330858
result:
ok "694330858"
Test #20:
score: 0
Accepted
time: 107ms
memory: 12712kb
input:
93589 51398 3 7 21 23 25 29 31 33 35 37 39 41 43 47 49 53 55 61 63 77 83 85 89 95 99 105 109 113 117 125 127 129 135 139 141 147 151 155 157 159 163 165 167 171 173 179 183 185 187 197 201 207 211 217 219 221 233 239 241 251 257 261 265 267 269 273 275 283 287 289 291 295 297 305 307 313 315 317 321...
output:
777536233
result:
ok "777536233"
Test #21:
score: 0
Accepted
time: 133ms
memory: 13192kb
input:
100000 62633 3 5 9 13 15 17 19 21 23 27 33 37 39 41 45 49 51 53 55 61 63 65 69 71 73 77 81 85 87 89 91 95 97 99 103 105 107 109 111 115 117 119 123 125 127 129 133 137 139 141 143 145 147 149 153 159 161 163 165 167 173 177 179 181 183 187 193 195 197 199 209 211 213 215 217 221 223 225 227 233 235 ...
output:
737504170
result:
ok "737504170"
Test #22:
score: 0
Accepted
time: 123ms
memory: 12968kb
input:
100000 62720 3 5 7 9 13 15 21 23 25 27 33 39 45 47 49 51 55 59 61 69 73 77 79 83 87 89 91 95 97 101 105 107 109 115 125 129 137 139 141 143 145 149 151 153 157 161 169 171 173 175 177 181 183 189 191 193 195 197 199 209 213 217 219 221 225 227 229 231 233 235 237 241 245 247 249 251 253 255 259 261 ...
output:
617748342
result:
ok "617748342"
Test #23:
score: 0
Accepted
time: 130ms
memory: 12956kb
input:
100000 61952 1 5 11 13 15 19 21 23 25 29 33 35 39 43 45 47 49 57 59 61 63 67 71 73 75 77 79 81 83 85 87 91 93 99 101 103 107 109 115 117 121 123 125 129 133 137 143 147 149 153 155 157 161 169 173 175 179 181 183 185 187 189 191 193 199 201 211 217 219 221 225 229 231 235 239 243 245 247 251 253 255...
output:
610444772
result:
ok "610444772"
Test #24:
score: 0
Accepted
time: 127ms
memory: 12988kb
input:
100000 62478 7 9 11 15 19 21 23 25 29 31 33 35 37 39 43 45 47 51 53 55 57 59 61 65 67 75 79 83 93 95 97 99 101 103 109 111 113 115 119 121 123 137 143 145 147 149 151 157 167 169 171 175 177 179 181 185 187 189 191 193 195 197 199 207 209 211 215 217 221 223 227 231 233 235 239 241 243 245 247 249 2...
output:
35574634
result:
ok "35574634"
Test #25:
score: 0
Accepted
time: 127ms
memory: 12968kb
input:
100000 62512 1 3 5 7 9 13 17 23 25 27 31 33 35 37 39 41 45 47 53 55 57 59 61 63 65 69 71 73 75 77 81 83 89 91 93 97 99 101 103 105 107 109 111 117 121 123 125 127 129 133 135 137 139 141 153 155 157 161 163 165 167 169 171 175 181 183 187 189 191 193 195 199 203 207 209 213 219 223 225 227 229 231 2...
output:
576341038
result:
ok "576341038"
Test #26:
score: 0
Accepted
time: 121ms
memory: 13040kb
input:
100000 25239 3 7 9 11 17 19 23 33 43 47 51 57 65 69 77 79 93 113 121 123 145 147 151 153 161 165 169 173 175 179 181 185 191 197 199 201 209 213 215 217 219 227 229 233 241 263 295 303 305 315 321 329 343 349 359 363 365 367 379 381 383 387 389 395 397 409 441 447 457 461 463 465 471 477 479 547 551...
output:
610186317
result:
ok "610186317"
Test #27:
score: 0
Accepted
time: 126ms
memory: 12812kb
input:
100000 24954 3 5 7 13 17 25 37 43 49 53 61 83 93 101 111 115 117 123 131 135 139 141 157 181 185 195 197 201 221 223 229 241 245 251 257 285 293 301 323 337 347 349 357 363 367 373 377 431 435 437 441 449 453 461 469 479 489 493 495 499 501 513 517 523 527 539 541 557 559 563 583 589 593 611 631 635...
output:
584892215
result:
ok "584892215"
Test #28:
score: 0
Accepted
time: 123ms
memory: 12840kb
input:
100000 25057 7 13 21 41 43 47 65 83 89 111 113 119 131 133 141 143 145 157 169 181 185 201 207 211 215 221 253 257 269 277 287 291 295 303 315 319 333 335 369 371 377 407 415 417 445 447 457 475 485 503 507 509 511 513 517 535 541 543 545 551 555 557 567 573 585 587 591 593 595 605 611 623 629 631 6...
output:
420635212
result:
ok "420635212"
Test #29:
score: 0
Accepted
time: 129ms
memory: 12884kb
input:
100000 53389 1 5 9 13 17 19 27 29 31 33 35 39 47 63 71 77 79 83 87 89 91 93 97 101 103 105 107 109 111 115 117 119 125 129 137 139 145 149 155 157 161 163 165 177 179 181 185 195 197 199 207 209 217 219 221 223 225 227 229 233 235 239 245 247 251 253 257 259 267 269 273 275 277 281 285 287 289 291 2...
output:
272341848
result:
ok "272341848"
Test #30:
score: 0
Accepted
time: 131ms
memory: 12992kb
input:
100000 63131 1 3 7 9 11 13 15 17 19 21 23 27 29 31 37 39 41 45 47 49 61 63 65 69 71 73 77 85 87 91 95 99 101 103 105 107 111 113 117 119 121 125 127 129 133 137 141 143 145 147 149 153 155 157 161 163 171 173 177 179 181 183 185 187 191 193 195 197 199 201 203 207 209 213 215 225 227 233 235 239 241...
output:
486074251
result:
ok "486074251"
Test #31:
score: 0
Accepted
time: 126ms
memory: 13004kb
input:
100000 65584 1 3 7 9 11 13 15 17 21 23 29 31 33 37 41 45 47 51 53 57 63 65 69 71 75 77 79 85 95 97 101 107 109 111 113 117 119 121 125 129 131 133 135 139 145 151 155 157 159 167 169 173 177 179 181 183 189 195 199 203 205 215 217 219 221 225 231 233 235 237 241 245 251 255 263 265 267 271 273 275 2...
output:
300548747
result:
ok "300548747"
Test #32:
score: 0
Accepted
time: 130ms
memory: 13068kb
input:
100000 85028 1 3 5 7 9 11 13 15 17 21 23 29 31 33 35 37 39 41 45 47 49 51 53 55 59 61 63 65 67 69 71 73 75 77 79 81 85 87 89 91 93 95 97 99 101 103 105 107 109 111 115 117 119 121 129 131 133 135 137 139 141 143 145 149 151 153 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 ...
output:
771549211
result:
ok "771549211"
Test #33:
score: 0
Accepted
time: 127ms
memory: 13076kb
input:
100000 85689 1 3 5 7 9 11 13 19 23 25 29 33 37 39 41 43 45 47 49 53 55 57 59 61 63 65 67 69 71 73 75 77 79 83 85 87 89 91 93 97 99 101 103 105 107 109 111 113 117 121 123 125 127 129 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 175 177 183 187 189 191 193 195 197 1...
output:
559777459
result:
ok "559777459"
Test #34:
score: 0
Accepted
time: 126ms
memory: 13080kb
input:
100000 92620 1 3 5 7 9 11 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 147 149 153 155 157 159 165 167 169 171 173 175 177 179 181 183...
output:
636710940
result:
ok "636710940"
Test #35:
score: 0
Accepted
time: 131ms
memory: 13060kb
input:
100000 98228 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 1...
output:
997403689
result:
ok "997403689"
Test #36:
score: 0
Accepted
time: 120ms
memory: 13008kb
input:
100000 88348 1 3 5 7 9 13 15 17 19 21 25 27 29 33 37 39 41 43 47 49 51 55 57 59 61 65 67 69 71 73 75 77 79 81 83 85 87 89 93 95 97 99 101 103 105 109 111 115 117 121 123 125 127 129 131 133 135 137 139 143 145 147 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 19...
output:
238193664
result:
ok "238193664"
Test #37:
score: 0
Accepted
time: 129ms
memory: 13104kb
input:
100000 94819 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 91 93 95 97 99 101 103 105 107 109 113 115 117 119 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 1...
output:
108236721
result:
ok "108236721"
Test #38:
score: 0
Accepted
time: 132ms
memory: 13020kb
input:
100000 85432 1 3 9 11 13 15 17 19 21 23 25 27 29 31 35 37 41 43 45 47 49 53 55 57 61 63 65 67 69 75 77 79 81 83 87 89 91 93 95 97 99 101 103 105 107 109 111 115 117 121 123 125 127 131 133 135 137 139 143 145 149 151 153 155 157 159 161 163 165 167 169 173 175 177 183 187 189 191 193 195 197 199 201...
output:
784268076
result:
ok "784268076"
Test #39:
score: 0
Accepted
time: 127ms
memory: 13040kb
input:
100000 87305 1 3 5 7 9 11 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 55 57 61 63 65 67 71 73 75 77 79 81 83 85 87 89 91 93 95 99 101 103 105 107 111 113 115 117 119 121 123 125 127 129 131 133 135 137 143 145 147 149 151 153 155 157 159 165 167 171 173 175 177 179 183 185 187 189 191 1...
output:
149630632
result:
ok "149630632"
Test #40:
score: 0
Accepted
time: 122ms
memory: 12988kb
input:
99999 85201 1 3 5 7 9 11 13 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 103 105 107 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 157 161 163 165 167 169 171 173 175 177 179 181 1...
output:
440345213
result:
ok "440345213"
Test #41:
score: 0
Accepted
time: 127ms
memory: 13236kb
input:
99999 95806 1 3 5 7 9 11 15 19 21 23 25 27 29 31 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 87 91 93 95 97 99 101 103 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 173 175 177 179 181 183 1...
output:
501450066
result:
ok "501450066"
Test #42:
score: 0
Accepted
time: 127ms
memory: 12968kb
input:
99999 86821 1 3 5 7 9 11 15 17 19 21 25 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 77 79 81 83 85 87 89 95 99 101 105 107 109 113 115 117 119 121 123 125 127 131 133 135 137 139 141 143 145 147 149 151 153 155 159 161 163 165 169 171 173 175 177 179 181 183 185 189 191 193 ...
output:
751814239
result:
ok "751814239"
Test #43:
score: 0
Accepted
time: 126ms
memory: 13192kb
input:
99999 95752 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171...
output:
581742233
result:
ok "581742233"
Test #44:
score: 0
Accepted
time: 130ms
memory: 13200kb
input:
99999 95760 1 3 5 7 9 11 13 17 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 153 155 157 159 161 163 165 167 169 171 173 175 177 ...
output:
138387454
result:
ok "138387454"
Test #45:
score: 0
Accepted
time: 126ms
memory: 13044kb
input:
99999 91930 1 3 5 7 9 11 13 15 17 19 23 25 27 31 33 35 37 39 41 43 45 47 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 155 157 159 161 163 165 167 169 171 173 175 177 179...
output:
741500441
result:
ok "741500441"
Test #46:
score: 0
Accepted
time: 130ms
memory: 13112kb
input:
99999 94888 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 17...
output:
974503537
result:
ok "974503537"
Test #47:
score: 0
Accepted
time: 119ms
memory: 13056kb
input:
99999 95733 1 3 5 7 9 11 13 15 17 19 23 25 27 29 33 35 37 39 41 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 ...
output:
448105112
result:
ok "448105112"
Test #48:
score: 0
Accepted
time: 5ms
memory: 8464kb
input:
1 1 1
output:
1
result:
ok "1"
Test #49:
score: 0
Accepted
time: 130ms
memory: 13336kb
input:
100000 100000 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 1...
output:
749028041
result:
ok "749028041"
Test #50:
score: 0
Accepted
time: 63ms
memory: 10608kb
input:
50000 50000 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171...
output:
769389319
result:
ok "769389319"
Test #51:
score: 0
Accepted
time: 125ms
memory: 13148kb
input:
99999 99999 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171...
output:
481565462
result:
ok "481565462"
Test #52:
score: 0
Accepted
time: 124ms
memory: 12676kb
input:
100000 1 1
output:
638474417
result:
ok "638474417"
Test #53:
score: 0
Accepted
time: 0ms
memory: 8744kb
input:
2 1 1
output:
24
result:
ok "24"
Test #54:
score: 0
Accepted
time: 53ms
memory: 10464kb
input:
50000 25000 5 11 13 15 17 21 29 35 37 39 47 49 51 53 55 57 59 63 65 67 69 73 75 83 91 105 107 113 117 123 129 131 133 135 137 139 149 151 153 159 161 163 171 177 183 187 189 195 203 207 209 211 213 217 229 231 237 245 249 251 259 263 265 269 271 275 279 281 283 285 289 293 295 299 305 307 311 313 31...
output:
215582594
result:
ok "215582594"
Test #55:
score: 0
Accepted
time: 122ms
memory: 12872kb
input:
100000 50000 9 13 15 17 23 27 35 37 39 43 47 53 55 57 65 77 81 85 87 91 95 97 101 105 107 109 111 115 117 125 131 137 139 147 149 151 155 161 167 169 171 173 179 187 189 195 201 205 213 217 219 221 227 231 235 237 239 241 243 249 251 253 255 261 263 267 271 279 289 299 303 305 307 311 315 317 321 32...
output:
638474417
result:
ok "638474417"
Extra Test:
score: 0
Extra Test Passed