QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#631332 | #8691. Square Root Partitioning | hos_lyric | AC ✓ | 166ms | 23768kb | C++14 | 12.0kb | 2024-10-12 00:48:20 | 2024-10-12 00:48:20 |
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")
#ifndef LIBRA_OTHER_INT128_H_
#define LIBRA_OTHER_INT128_H_
#include <stdio.h>
#include <iostream>
constexpr unsigned __int128 toUInt128(const char *s) {
unsigned __int128 x = 0;
for (; *s; ++s) x = x * 10 + (*s - '0');
return x;
}
constexpr __int128 toInt128(const char *s) {
if (*s == '-') return -toInt128(s + 1);
__int128 x = 0;
for (; *s; ++s) x = x * 10 + (*s - '0');
return x;
}
unsigned __int128 inUInt128() {
static char buf[41];
scanf("%s", buf);
return toUInt128(buf);
}
__int128 inInt128() {
static char buf[41];
scanf("%s", buf);
return toInt128(buf);
}
void out(unsigned __int128 x) {
static char buf[41];
int len = 0;
do { buf[len++] = '0' + static_cast<int>(x % 10); } while (x /= 10);
for (int i = len; --i >= 0; ) putchar(buf[i]);
}
void out(__int128 x) {
if (x < 0) {
putchar('-');
out(-static_cast<unsigned __int128>(x));
} else {
out(static_cast<unsigned __int128>(x));
}
}
std::ostream &operator<<(std::ostream &os, unsigned __int128 x) {
static char buf[41];
int len = 0;
do { buf[len++] = '0' + static_cast<int>(x % 10); } while (x /= 10);
for (int i = len; --i >= 0; ) os << buf[i];
return os;
}
std::ostream &operator<<(std::ostream &os, __int128 x) {
if (x < 0) {
os << '-' << -static_cast<unsigned __int128>(x);
} else {
os << static_cast<unsigned __int128>(x);
}
return os;
}
#endif // LIBRA_OTHER_INT128_H_
////////////////////////////////////////////////////////////////////////////////
// floor(a b / 2^128)
inline unsigned __int128 mul128High(unsigned __int128 a, unsigned __int128 b) {
const unsigned __int128 a0 = static_cast<unsigned long long>(a), a1 = a >> 64;
const unsigned __int128 b0 = static_cast<unsigned long long>(b), b1 = b >> 64;
return ((((a0 * b0) >> 64) + static_cast<unsigned long long>(a0 * b1) + static_cast<unsigned long long>(a1 * b0)) >> 64) + ((a0 * b1) >> 64) + ((a1 * b0) >> 64) + a1 * b1;
}
// Hold y := (2^128 x) mod M
template <int ID> struct RMModInt128 {
static unsigned __int128 M;
static unsigned __int128 INV_M; // M^-1 mod 2^128
static unsigned __int128 TWO256; // 2^256 mod M
static void setM(unsigned __int128 m) {
assert(m & 1); assert(1 <= m); assert(!(m >> 127));
M = m;
INV_M = (3 * M) ^ 2;
for (int i = 0; i < 5; ++i) INV_M *= (2 - M * INV_M);
TWO256 = (-M) % M;
for (int i = 0; i < 128; ++i) TWO256 = ((TWO256 <<= 1) >= M) ? (TWO256 - M) : TWO256;
}
// (2^-128 a) mod M (0 <= a < 2^128 m)
static inline unsigned __int128 reduce(unsigned __int128 a) {
const unsigned __int128 c = -mul128High(INV_M * a, M);
return (c >= M) ? (c + M) : c;
}
// (2^-128 a b) mod M (0 <= a b < 2^128 m)
static inline unsigned __int128 mulReduce(unsigned __int128 a, unsigned __int128 b) {
const unsigned __int128 c = mul128High(a, b) - mul128High(INV_M * (a * b), M);
return (c >= M) ? (c + M) : c;
}
unsigned __int128 y;
RMModInt128() : y(0U) {}
RMModInt128(unsigned x_) : y(mulReduce(TWO256, x_ % M)) {}
RMModInt128(unsigned long long x_) : y(mulReduce(TWO256, x_ % M)) {}
RMModInt128(unsigned __int128 x_) : y(mulReduce(TWO256, x_ % M)) {}
RMModInt128(int x_) : y(mulReduce(TWO256, ((x_ %= static_cast<__int128>(M)) < 0) ? (x_ + static_cast<__int128>(M)) : x_)) {}
RMModInt128(long long x_) : y(mulReduce(TWO256, ((x_ %= static_cast<__int128>(M)) < 0) ? (x_ + static_cast<__int128>(M)) : x_)) {}
RMModInt128(__int128 x_) : y(mulReduce(TWO256, ((x_ %= static_cast<__int128>(M)) < 0) ? (x_ + static_cast<__int128>(M)) : x_)) {}
unsigned __int128 get() const { return reduce(y); }
RMModInt128 &operator+=(const RMModInt128 &a) { y = ((y += a.y) >= M) ? (y - M) : y; return *this; }
RMModInt128 &operator-=(const RMModInt128 &a) { y = ((y -= a.y) >= M) ? (y + M) : y; return *this; }
RMModInt128 &operator*=(const RMModInt128 &a) { y = mulReduce(y, a.y); return *this; }
RMModInt128 &operator/=(const RMModInt128 &a) { return (*this *= a.inv()); }
template <class T> RMModInt128 pow(T e) const {
if (e < 0) return inv().pow(-e);
for (RMModInt128 a = *this, b = 1U; ; a *= a) { if (e & 1) { b *= a; } if (!(e >>= 1)) { return b; } }
}
RMModInt128 inv() const {
unsigned __int128 a = M, b = reduce(reduce(y)); __int128 u = 0, v = 1;
for (; b; ) { const unsigned __int128 q = a / b; const unsigned __int128 c = a - q * b; a = b; b = c; const __int128 w = u - static_cast<__int128>(q) * v; u = v; v = w; }
assert(a == 1U); RMModInt128 r; r.y = u; r.y = (r.y >= M) ? (r.y + M) : r.y; return r;
}
RMModInt128 operator+() const { return *this; }
RMModInt128 operator-() const { RMModInt128 a; a.y = y ? (M - y) : 0U; return a; }
RMModInt128 operator+(const RMModInt128 &a) const { return (RMModInt128(*this) += a); }
RMModInt128 operator-(const RMModInt128 &a) const { return (RMModInt128(*this) -= a); }
RMModInt128 operator*(const RMModInt128 &a) const { return (RMModInt128(*this) *= a); }
RMModInt128 operator/(const RMModInt128 &a) const { return (RMModInt128(*this) /= a); }
template <class T> friend RMModInt128 operator+(T a, const RMModInt128 &b) { return (RMModInt128(a) += b); }
template <class T> friend RMModInt128 operator-(T a, const RMModInt128 &b) { return (RMModInt128(a) -= b); }
template <class T> friend RMModInt128 operator*(T a, const RMModInt128 &b) { return (RMModInt128(a) *= b); }
template <class T> friend RMModInt128 operator/(T a, const RMModInt128 &b) { return (RMModInt128(a) /= b); }
explicit operator bool() const { return y; }
bool operator==(const RMModInt128 &a) const { return (y == a.y); }
bool operator!=(const RMModInt128 &a) const { return (y != a.y); }
// !
bool operator<(const RMModInt128 &a) const { return (y < a.y); }
friend std::ostream &operator<<(std::ostream &os, const RMModInt128 &a) { return os << a.get(); }
};
template <int ID> unsigned __int128 RMModInt128<ID>::M;
template <int ID> unsigned __int128 RMModInt128<ID>::INV_M;
template <int ID> unsigned __int128 RMModInt128<ID>::TWO256;
////////////////////////////////////////////////////////////////////////////////
using RMM128ForPrime = RMModInt128<-20220617>;
template <class T> vector<T> merge(const vector<T> &a, const vector<T> &b) {
vector<T> c(a.size() + b.size());
std::merge(a.begin(), a.end(), b.begin(), b.end(), c.begin());
return c;
}
int bsf128(__int128 a) {
const long long a64 = a;
return a64 ? __builtin_ctzll(a64) : (64 + __builtin_ctzll(a >> 64));
}
__int128 gcd128(__int128 a, __int128 b) {
if (a < 0) a = -a;
if (b < 0) b = -b;
if (a == 0) return b;
if (b == 0) return a;
const int s = bsf128(a | b);
a >>= bsf128(a);
do {
b >>= bsf128(b);
if (a > b) swap(a, b);
b -= a;
} while (b);
return a << s;
}
// Checks if n is a prime using Miller-Rabin test
bool isPrime128(__int128 n) {
if (n <= 1 || !(n & 1)) return (n == 2);
RMM128ForPrime::setM(n);
const int s = bsf128(n - 1);
const __int128 d = (n - 1) >> s;
// Based on conjectures in Zhang, Two kinds of strong pseudoprimes up to 10^36.
for (const __int128 base : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71}) {
if (base >= n) continue;
RMM128ForPrime a = RMM128ForPrime(base).pow(d);
if (a.get() == 1 || static_cast<__int128>(a.get()) == n - 1) continue;
bool ok = false;
for (int i = 0; i < s - 1; ++i) {
if (static_cast<__int128>((a *= a).get()) == n - 1) {
ok = true;
break;
}
}
if (!ok) return false;
}
return true;
}
#include <chrono>
#ifdef LOCAL
mt19937_64 rng(58);
#else
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
using INT = __int128;
using Mint = RMModInt128<0>;
using Pair = pair<Mint, Mint>;
Pair operator+(const Pair &a, const Pair &b) { return make_pair(a.first + b.first, a.second + b.second); }
Pair operator-(const Pair &a, const Pair &b) { return make_pair(a.first - b.first, a.second - b.second); }
// Pair operator*(const Pair &a, const Pair &b) { return make_pair(a.first * b.first, a.first * b.second + a.second * b.first); }
Pair operator*(const Pair &a, Mint k) { return make_pair(a.first * k, a.second * k); }
Pair operator*(Mint k, const Pair &a) { return make_pair(k * a.first, k * a.second); }
Pair &operator+=(Pair &a, const Pair &b) { return a = a + b; }
Pair &operator-=(Pair &a, const Pair &b) { return a = a - b; }
// Pair &operator*=(Pair &a, const Pair &b) { return a = a * b; }
Pair &operator*=(Pair &a, Mint k) { return a = a * k; }
// constexpr Pair ZERO(0, 0);
INT rng127() {
return (INT)rng() << 63 ^ rng();
}
INT M;
bool isNonResidue(Mint a) {
return (a && a.pow((M - 1) / 2) != 1);
}
// (b + sqrt(b^2 - a))^((p+1)/2) in F_p(sqrt(b^2 - a))
Mint modSqrt(Mint a) {
Mint b, d;
for (; ; ) {
b = rng127();
d = b * b - a;
if (isNonResidue(d)) break;
}
Mint f0 = b, f1 = 1, g0 = 1, g1 = 0, tmp;
for (INT e = (M + 1) >> 1; e; e >>= 1) {
if (e & 1) {
tmp = (g0 * f0 + d * ((g1 * f1) )) ;
g1 = (g0 * f1 + g1 * f0) ;
g0 = tmp;
}
tmp = (f0 * f0 + d * ((f1 * f1) )) ;
f1 = (2 * f0 * f1) ;
f0 = tmp;
}
assert(g0 * g0 == a);
return g0;
}
int N;
char A[40][100'010];
int main() {
for (; ; ) {
M = ((INT)1<<125) + (rng127() >> 2);
if (isPrime128(M)) break;
}
Mint::setM(M);
// fixed non-residue
Mint R;
for (; ; ) {
R = rng127();
if (isNonResidue(R)) break;
}
cerr<<"M = "<<M<<", R = "<<R<<endl;
for (; ~scanf("%d", &N); ) {
for (int i = 0; i < N; ++i) {
scanf("%s", A[i]);
}
vector<Pair> fs(1 << (N/2)), gs(1 << (N - N/2));
fs[0] = gs[0] = Pair(0, 0);
for (int i = 0; i < N; ++i) {
Mint b = 0;
for (char *a = A[i]; *a; ++a) (b *= 10) += (*a - '0');
Pair c(0, 0);
if (isNonResidue(b)) {
c.second = modSqrt(R * b);
} else {
c.first = modSqrt(b);
}
cerr<<b<<": "<<c<<endl;
if (i < N/2) {
for (int h = 0; h < 1 << i; ++h) {
fs[h | 1 << i] = fs[h] - c;
fs[h] += c;
}
} else {
for (int h = 0; h < 1 << (i - N/2); ++h) {
gs[h | 1 << (i - N/2)] = gs[h] - c;
gs[h] += c;
}
}
}
sort(fs.begin(), fs.end());
sort(gs.begin(), gs.end());
long long ans = 0;
for (int x = 0, yL = 0, yR = 0; x < (int)fs.size(); ++x) {
for (; yL < (int)gs.size() && gs[yL] < fs[x]; ++yL) {}
for (; yR < (int)gs.size() && gs[yR] <= fs[x]; ++yR) {}
ans += (yR - yL);
}
assert(ans % 2 == 0);
ans /= 2;
printf("%lld\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6184kb
input:
3 2 2 8
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
4 4 9 25 49
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 27ms
memory: 21772kb
input:
36 1 1 1 1 1 1 1 1 1 1 1 1 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:
4537567650
result:
ok 1 number(s): "4537567650"
Test #4:
score: 0
Accepted
time: 115ms
memory: 23456kb
input:
36 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
output:
4537567650
result:
ok 1 number(s): "4537567650"
Test #5:
score: 0
Accepted
time: 51ms
memory: 21996kb
input:
36 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 2147483648 4294967296 8589934592 17179869184 34359738368
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 148ms
memory: 23768kb
input:
36 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: 0
Accepted
time: 51ms
memory: 21792kb
input:
36 1 4 16 64 256 1024 4096 16384 65536 262144 1048576 4194304 16777216 67108864 268435456 1073741824 4294967296 17179869184 68719476736 274877906944 1099511627776 4398046511104 17592186044416 70368744177664 281474976710656 1125899906842624 4503599627370496 18014398509481984 72057594037927936 2882303...
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
10 2209 9 729 169 25 169 289 1936 9 196
output:
6
result:
ok 1 number(s): "6"
Test #9:
score: 0
Accepted
time: 0ms
memory: 6216kb
input:
10 4 1 16 100 3969 784 9 625 676 16
output:
3
result:
ok 1 number(s): "3"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
10 49 4 16 36 400 289 1681 784 1296 9
output:
5
result:
ok 1 number(s): "5"
Test #11:
score: 0
Accepted
time: 1ms
memory: 5888kb
input:
10 25 900 256 225 9 169 1 361 169 289
output:
11
result:
ok 1 number(s): "11"
Test #12:
score: 0
Accepted
time: 2ms
memory: 5892kb
input:
10 729 324 4 36 36 225 81 81 256 1
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 0ms
memory: 5948kb
input:
25 5731236 7075600 6801664 224676 511225 3254416 3305124 28826161 2347024 4177936 5424241 2601 1232100 571536 2232036 4157521 271441 323761 3667225 797449 5740816 258064 670761 126025 18344089
output:
1234
result:
ok 1 number(s): "1234"
Test #14:
score: 0
Accepted
time: 3ms
memory: 6200kb
input:
25 1034289 83521 808201 6796449 159201 6969600 4900 152881 929296 4239481 4272489 1860496 1296 925444 43824400 1350244 3481 10660225 3511876 6061444 150544 334084 529 45369 29584
output:
1219
result:
ok 1 number(s): "1219"
Test #15:
score: 0
Accepted
time: 3ms
memory: 6196kb
input:
25 1162084 314721 285156 4000000 368449 2866249 47089 324 568516 2399401 58564 29584 506944 4000000 37249 576 62500 4000000 36 1849 107584 16 196 152100 2524921
output:
2573
result:
ok 1 number(s): "2573"
Test #16:
score: 0
Accepted
time: 0ms
memory: 6228kb
input:
25 10404 2027776 6400 11881 361 1352569 143641 81 2621161 20164 20449 2202256 1089 12100 1577536 5041 138384 3844 96100 324900 583696 342225 3896676 4000000 4000000
output:
2617
result:
ok 1 number(s): "2617"
Test #17:
score: 0
Accepted
time: 0ms
memory: 5992kb
input:
25 2742336 4000000 4000000 4000000 36 1580049 7056 25921 682276 400 680625 2812329 4000000 3968064 366025 4000000 269361 3407716 196249 826281 506944 806404 4000000 2461761 1081600
output:
0
result:
ok 1 number(s): "0"
Test #18:
score: 0
Accepted
time: 40ms
memory: 21720kb
input:
36 90601 54289 123904 313600 7056 5929 4761 225 330625 133956 156025 38416 57600 62500 52900 59049 900 9025 81 6889 148225 9604 97344 90601 74529 271441 88804 16 83521 119716 2500 1296 216225 83521 87025 113569
output:
15617032
result:
ok 1 number(s): "15617032"
Test #19:
score: 0
Accepted
time: 49ms
memory: 21984kb
input:
36 59845696 100000000 1440000 85322169 100000000 9492561 25847056 30802500 160000 36060025 38340864 56761156 4239481 4977361 100000000 1923769 7327849 1731856 459684 100000000 14661241 100000000 100000000 31854736 74805201 17397241 27092025 35307364 6568969 37124649 100000000 55249489 100000000 1000...
output:
0
result:
ok 1 number(s): "0"
Test #20:
score: 0
Accepted
time: 55ms
memory: 21944kb
input:
36 70644025 84953089 37761025 100000000 82373776 76108176 74097664 38539264 32330596 28890625 13293316 38688400 1083681 32080896 1343281 9126441 11363641 1406596 100000000 73119601 2788900 1532644 5736025 100000000 29942784 100000000 61340224 13957696 50083929 906304 14953689 69488896 3150625 116964...
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 49ms
memory: 21848kb
input:
36 98267569 24964 52243984 168921 64016001 100000000 784 1664100 11648569 2184484 83960569 40411449 74529 3025 63920025 318096 25563136 20529961 986049 42328036 28224 59783824 237169 71622369 442225 13024881 6041764 100000000 67601284 34969 624100 22486564 1104601 50822641 1121481 9523396
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 54ms
memory: 21776kb
input:
36 7767369 1125721 100000000 42915601 41602500 1168561 100000000 100000000 876096 75625 799236 1708249 9102289 34727449 15327225 889249 86899684 410881 86564416 33292900 1658944 82646281 70862724 861184 33396841 32661225 7396 18835600 39062500 100000000 100000000 504100 729316 80640400 1089 22801
output:
767831
result:
ok 1 number(s): "767831"
Test #23:
score: 0
Accepted
time: 51ms
memory: 21788kb
input:
36 62236321 1723969 109181601 442225 26224641 1907161 55890576 58844241 119880601 86657481 163072900 599076 194937444 56310016 13498276 12996025 86266944 84052224 85803169 35224225 40144896 175377049 423783396 2582449 7139584 59290000 61277584 2996361 68277169 121 11526025 7952400 41822089 10291264 ...
output:
573433
result:
ok 1 number(s): "573433"
Test #24:
score: 0
Accepted
time: 48ms
memory: 21880kb
input:
36 123520996 2879809 14273284 38887696 301647424 142110241 66308449 1163560321 2706025 98644624 740547369 16785409 166487409 684397921 7806436 1641546256 13749264 3405539449 38987536 308318481 1402652304 647702500 506880196 57350329 75759616 38278969 234702400 1932393681 113316025 403225 77862976 27...
output:
214465
result:
ok 1 number(s): "214465"
Test #25:
score: 0
Accepted
time: 46ms
memory: 21844kb
input:
36 15389929 888218809 1196744836 404492544 886788841 25310961 53655625 141657604 929640100 559504 3048516 1000000 13461561 36024004 120409 29441476 25563136 62315236 1664100 16329681 77158656 5262436 40576900 144024001 132526144 343435024 393625600 35141184 18879025 2371600 86471401 561001 6066369 6...
output:
334960
result:
ok 1 number(s): "334960"
Test #26:
score: 0
Accepted
time: 51ms
memory: 21776kb
input:
36 295564864 670761 24850225 538286401 7376656 8340544 40908816 183277444 272943441 9060100 41396356 292923225 174504100 16834609 1194649 77387209 16000000 30276 30276 272943441 18020025 24850225 174504100 295564864 251507881 412617969 251507881 201601 7376656 23011209 136900 63345681 63345681 18327...
output:
405383
result:
ok 1 number(s): "405383"
Test #27:
score: 0
Accepted
time: 50ms
memory: 21732kb
input:
36 232654009 137358400 337861161 337861161 232654009 137358400 280428516 113379904 275560000 64368529 6533136 270799936 22353984 5621641 101002500 101002500 314743081 55726225 399080529 314743081 399080529 280428516 22353984 6533136 86490000 64368529 275560000 25310961 86490000 270799936 25310961 26...
output:
560476
result:
ok 1 number(s): "560476"
Test #28:
score: 0
Accepted
time: 42ms
memory: 17776kb
input:
35 3433609 37957921 15594601 712249344 629859409 128300929 402122809 309724801 2544798916 4915089 2154166569 2965284 10705984 105042001 100821681 143161225 2325625 39325441 3583449 284495689 30426256 52591504 5626384 256320100 161467849 690007824 41550916 147209689 5447556 73547776 268435456 8242641...
output:
127533
result:
ok 1 number(s): "127533"
Test #29:
score: 0
Accepted
time: 39ms
memory: 17636kb
input:
35 130074025 11276164 42224004 446224 106172416 781456 39942400 38700841 118592100 48972004 24265476 1378933956 2686321 27050401 302516449 402443721 1985281 3723806529 1377968641 443397249 14653584 27973521 2980941604 4553956 1016015625 47692836 194909521 55308969 67174416 19456921 13771521 2683044 ...
output:
115420
result:
ok 1 number(s): "115420"
Test #30:
score: 0
Accepted
time: 42ms
memory: 17744kb
input:
35 104182849 93470224 1848054121 260564164 4100625 17530969 59197636 25959025 153809604 55995289 1228502500 7447441 332770564 5536609 192959881 465566929 1254400 395214400 383689744 396328464 377602624 726194704 50481025 56445169 88209 3578193124 2405601 66699889 10240000 39012516 241398369 4862025 ...
output:
119754
result:
ok 1 number(s): "119754"
Test #31:
score: 0
Accepted
time: 41ms
memory: 17632kb
input:
35 67897600 46949904 3048516 79245604 359367849 30991489 676832256 177715561 206468161 79245604 211818916 3892729 206468161 11664 211818916 13032100 67897600 30991489 255808036 255808036 11833600 877699876 47238129 489913956 2792241 2792241 207792225 115562500 232898121 57198969 51529 11102224 11556...
output:
192453
result:
ok 1 number(s): "192453"
Test #32:
score: 0
Accepted
time: 42ms
memory: 21980kb
input:
36 5466405675975732 16064210249492 447267173917952 880688147602752 880688147602752 510687716057300 2670600414297168 50097937713332 1898914732710548 8908400885300 273695163852368 3492449483073012 336155780345300 5241783074714388 18914898532788 7446695923712 296733379366352 811253525845328 89593787548...
output:
8212198
result:
ok 1 number(s): "8212198"
Test #33:
score: 0
Accepted
time: 53ms
memory: 21992kb
input:
36 65694759899619176198186243627726332735870055782623571764599503385874531241012477271247026513399828509400000 40166019156620875936950500516135473497184087719607673905469940362369937936743345957476494314384790505042535 361968496350590932656205551121400040594208911618871179245484873403527335531401849...
output:
597463
result:
ok 1 number(s): "597463"
Test #34:
score: 0
Accepted
time: 153ms
memory: 22992kb
input:
36 665389072123636945490529642714628528344634804227905384659457915311566721771573587884680347993459836155318124419123928691913147025266905964711041070287347229893893184767072517995510369443049755746331282439302137679167766107733848808413041851894852831481547768246229115452050431893302389812647103971...
output:
160
result:
ok 1 number(s): "160"
Test #35:
score: 0
Accepted
time: 48ms
memory: 21880kb
input:
36 2577282270778907 288776223465825728 808097308444412 5222860064974592 19120818642266288 128918889086972 963796469528268 15172988757692 9759508147672832 30266389633299200 5246845613522288 64627728031292 23758081190675 34211636914572 2024357213880000 1179547962812012 52138585266738075 12068683503776...
output:
0
result:
ok 1 number(s): "0"
Test #36:
score: 0
Accepted
time: 52ms
memory: 21832kb
input:
36 18914754220263927900461298995015459398197056648077998141040595133836557190756084783864823182217681708836544 3021571304212064965115915015515511310108469274177711125842332135563634105031833619477564962417695657371454656 1680355729837238841904282391292515383380568065468860025045055222143504950741993...
output:
0
result:
ok 1 number(s): "0"
Test #37:
score: 0
Accepted
time: 145ms
memory: 23372kb
input:
36 334616228189511899591000938507255409534807058544935707975931681196626108714722412566693130196991719290393649083713655594192801813472041459373647979850892982996427958069165832927818259384666966718506571159831026040368509980242769706194733337242804988913287885368344962430280792121348076095964272903...
output:
0
result:
ok 1 number(s): "0"
Test #38:
score: 0
Accepted
time: 48ms
memory: 21720kb
input:
36 2440327198696800 63547234682836632 82092606964160352 272768673472512 460346062626072 9429094859746968 399242748495192 4541411406733152 29462148008068608 91160409452275800 6819216836812800 512359986968088 7492636244399712 290083091222232 2558271816435552 4143114563634648 6625773746952192 249423510...
output:
2981864
result:
ok 1 number(s): "2981864"
Test #39:
score: 0
Accepted
time: 58ms
memory: 19820kb
input:
36 9316609578845322779203494372589235426070543991143880724541297722859597042399326469350196181313044870449038 382578554898003417601262820191922841597409716050416303005688950693987936749417879217660239586792283593584632 115782122432910615088463182613677981090877010774623436901221765402470127578138855...
output:
277583
result:
ok 1 number(s): "277583"
Test #40:
score: 0
Accepted
time: 50ms
memory: 21876kb
input:
36 615802232408 4232973652826112 524403949004568 67455675562108 1613142295901912 40312144486808 169615861702957168 129496488504700 7740786739608 357394312155800 230895301505112 13761398648192 5132623921243072 37827566865829423 518878184824597383 8555070683288 3963558903828950 5883201493088 136030713...
output:
6056
result:
ok 1 number(s): "6056"
Test #41:
score: 0
Accepted
time: 49ms
memory: 22060kb
input:
36 23227466182859633312548652866753475451995815161603822436426725139785346413257819992289331326688381026626708 256495818165664157943599808333885619863755177490548924766432053072625732951199406528854000068901449264501268 21714097487314116077186465509361117546588463577195761301212057787077925292187280...
output:
5900
result:
ok 1 number(s): "5900"
Test #42:
score: 0
Accepted
time: 158ms
memory: 23100kb
input:
36 103200728183477025016016828204458016694132907458064842980280105627776152553769182002675572035251861824974491574470863576666995962673750917832056626525448951781531738665340053299631342362412786099941828271073370219775466139015424876422211480741311719128531001014378555416743759480495293764742497964...
output:
81
result:
ok 1 number(s): "81"
Test #43:
score: 0
Accepted
time: 147ms
memory: 23056kb
input:
36 209182066224597405646539749287984228480867680394969601982518219785031698193870523742058719451109533678206050083977414934153638962306348414171298276283997507869242726113548256132997070383094397423300202180136366927788377588308160334210188548766694893348597393405338906551039591407053821054999619478...
output:
4
result:
ok 1 number(s): "4"
Test #44:
score: 0
Accepted
time: 163ms
memory: 23060kb
input:
36 135801503300639992595413118268956460679129919558683284993511618231038952571683024022928197917865996313564402052762546434680062693278005651819957995104650389419989668882854301384886061381104470815808102903341705265738438475274401682702391541474396050116204248619324514517815575456983549565135156819...
output:
512
result:
ok 1 number(s): "512"
Test #45:
score: 0
Accepted
time: 166ms
memory: 23168kb
input:
36 548287785486300145746444570764493558268989223804860233691906150698707307217326077673847727292841254271818086298736415336274599568737237806700207306046383307107895062788024942700749807161903876647227211222482532450839933150974612019970070361463924553514904964367428577158807555253697561861879178042...
output:
131072
result:
ok 1 number(s): "131072"
Test #46:
score: 0
Accepted
time: 145ms
memory: 23184kb
input:
36 202942125108156546645442588390343525691331772581380307349843194239213726554187446169216153143158483056652833380921709407179453507306192837964555028601274209769492459215671842047792786178142820648054653930062596478377591039969449388842178185980592593936186179628942034596105073702096001586715152256...
output:
5165416
result:
ok 1 number(s): "5165416"
Test #47:
score: 0
Accepted
time: 163ms
memory: 23248kb
input:
36 420002505619732400132506563514173484353542471357230216870188049264560065796601655054693405294155770373853525822437260353329078623104065382261590731150309531026319717544056080792735725660714568963743955311772809888681555213885840588861066381230549857601164320594125647562891939940057490857711162514...
output:
0
result:
ok 1 number(s): "0"
Test #48:
score: 0
Accepted
time: 158ms
memory: 23188kb
input:
36 276229334014283426563724229162088372583477265974452791945611385233995987882259256490265509707656171741804578365309796345457627952854449131958589204140820128245577865512641300486478734838321601056415577928963307096093134442684814257987912986708580240272296299122888631678874349213047153524610424102...
output:
0
result:
ok 1 number(s): "0"
Test #49:
score: 0
Accepted
time: 144ms
memory: 23188kb
input:
36 312799295679518169740198757505029032610585016172972471258574929000628113674382931635901885159768852665008032638569406596116004049223254147072265394556111756558582579457457013767919290868939784885825224672778459901145801480443224923745232302478414806737171855169563274582068288746082702801822850997...
output:
0
result:
ok 1 number(s): "0"
Test #50:
score: 0
Accepted
time: 137ms
memory: 23112kb
input:
36 440879596265641066921576888371543366198081399673789674272975729260296807949205228647169729624888809136648337338093951928336145886553347285579427437992420290160155454694901674669240434657697971156828997993669374490828690399869569988994359989348507079044597887485091862115580833100686279882739524857...
output:
1
result:
ok 1 number(s): "1"
Test #51:
score: 0
Accepted
time: 142ms
memory: 23420kb
input:
36 629482564964457786392989664048239322131025979417530916519525295420032019722298943129301619820381919406007448543618072775444291352759496088961180376125478574593739108364274028653731535511648102081901534056312046072816828297880829768977581369811724775703172494393670132352601963409343037377671758560...
output:
2
result:
ok 1 number(s): "2"
Test #52:
score: 0
Accepted
time: 139ms
memory: 23112kb
input:
36 578524556307660196578325686429381964421662360352179316472536762879063089441779234270299674609324086177315969424191814038774983085118272930170488814326491350788307603771265735581922047282305859878699002316976975471140312469546596846463196146830766051562215763037262417139235109729308123949784835159...
output:
9787217
result:
ok 1 number(s): "9787217"
Test #53:
score: 0
Accepted
time: 139ms
memory: 23108kb
input:
36 200542902986347649011648346276606160370184845725317168094832187967095887351909163201504697725285625673781193251676230160625546941886083941460251919395306472488431902218562646112859265426727074854134177258749024010608016846209168195346353624796056386035915956502726675691303715536789583834829285028...
output:
0
result:
ok 1 number(s): "0"
Test #54:
score: 0
Accepted
time: 141ms
memory: 23180kb
input:
36 317954234945263032348723759456032010853787393739365922707192932864095077394489112254550123048229827204731490625780193625395250587511445780232944492575352961648510256412066660060075195617722975855440292491711667322239098090667891188220509996636980609924356371704663335738973918093915318886222188638...
output:
4537567650
result:
ok 1 number(s): "4537567650"
Test #55:
score: 0
Accepted
time: 133ms
memory: 23108kb
input:
36 510254908100600921226655512949588154824282735090962369944798385024717642004826569207048205084614203788893706021226882848411142963481933966733637428980033057223077516905110009755778691817906427496584794845565066093956370298209824114516842588373673121454747524195759941389635399693374942632572744177...
output:
1310475600
result:
ok 1 number(s): "1310475600"
Test #56:
score: 0
Accepted
time: 140ms
memory: 23168kb
input:
36 508629947574957684462027904148970689122291887414944972275756795040034290700272793023991514500621615911793427719262403515097960570641175221446772610813021516133819082540179464323423796215618154547200680967152643572565553775265635810583729963805262768882015072949368928920864618289264722157782162388...
output:
4608000
result:
ok 1 number(s): "4608000"
Test #57:
score: 0
Accepted
time: 159ms
memory: 23176kb
input:
36 504303845838930201476789943372468412987216250469422416838062096710326868171701076220547028041089435981042586913313400123683664706177396832198078447343389624363294449517004050506480449433751135918262207924104250163763065332963874527030978890793948686674554575903991409092870389613005207689668304982...
output:
131072
result:
ok 1 number(s): "131072"
Test #58:
score: 0
Accepted
time: 139ms
memory: 23372kb
input:
36 274862406262990865784220512684031678638868129271471309867404653937227044498221327002342408710088688300908749884961335471516259087758820878918369246517957498585278595577787381464753743959258502780052944212907273595679172202909469776679944608286374185211961536506787002911339920389879395808066379785...
output:
752461732
result:
ok 1 number(s): "752461732"
Test #59:
score: 0
Accepted
time: 145ms
memory: 23368kb
input:
36 124006536845658336606221736514522763297113842463370150961850199366642140644268967750443720320815901367681234535391719066443763204341080009967821886370879402592592884758811132472595332757460907492275141192342871476523884270136595453656109852129051572829502975983426906119557200310369556473011401773...
output:
0
result:
ok 1 number(s): "0"
Test #60:
score: 0
Accepted
time: 153ms
memory: 23084kb
input:
36 114541690120599181619734457267637289218936836896949195593654530760348431548024180259228297086200631168375586265748329965715808841585028676099926647460761686293558638760186965904433717073723638445535510800567158594403320447854856182182070087955368890436149020939083691475583121659655042813026403336...
output:
3359232
result:
ok 1 number(s): "3359232"
Test #61:
score: 0
Accepted
time: 145ms
memory: 23164kb
input:
36 273233582611421067165077690636134881827460148994454670556759843055794325503815435609532242609760837084494499100749421776238436101601653404929096198809701581054799538879122540895215560967079490933637825056590189314818279436512865192282398138686654317573991279343853748792220237348672394502207102150...
output:
4147200
result:
ok 1 number(s): "4147200"
Test #62:
score: 0
Accepted
time: 136ms
memory: 23096kb
input:
36 179744983061786605855702663048950495550755326487099110597228259315562560274728760758011308375914837389109428285091805543095892330442870869942283848700961187498059674004712873745463026514215695421082139630394405485988712233729265796807281858540430749322911169068373048677419439849631439970513449971...
output:
121741200
result:
ok 1 number(s): "121741200"
Test #63:
score: 0
Accepted
time: 137ms
memory: 23104kb
input:
36 723550974404899248106344525092994798073492943182349292439032919712471941776214766274150341022086234303050630337993779118362538466759680503093725856643592346595517948632605291393205916630628380569621602436848843620396820394089737899932141962628122773627303140898608278732096422910047383386161924301...
output:
847154880
result:
ok 1 number(s): "847154880"
Test #64:
score: 0
Accepted
time: 150ms
memory: 23176kb
input:
36 599877597284386394180197154687900239032950816971826021422958884981026042296062779725013991069523644634424159245092537076779132489378418698385235222984101371207614867477104017332795924753051836411564043739498118206486689844779009658655992203956683864727054630229221422874600400195872080423884711859...
output:
5824000
result:
ok 1 number(s): "5824000"
Test #65:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
2 1000000007 1000000007
output:
1
result:
ok 1 number(s): "1"
Test #66:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
2 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0
result:
ok 1 number(s): "0"
Test #67:
score: 0
Accepted
time: 155ms
memory: 23180kb
input:
36 223357702077441702982726240764881799687070222227110492566006880026062436333560596525356351868085034941380726419996285614783698712108245881621477341462880259594011754197162818291696024902882914414566273552793949845200991766654244546002321795614441799240854974447702279380537964533576596890153311972...
output:
1814400
result:
ok 1 number(s): "1814400"