QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#463030 | #249. Miller Rabin 算法 | NOI_AK_ME# | AC ✓ | 25ms | 4000kb | C++23 | 18.2kb | 2024-07-04 11:40:09 | 2024-07-04 11:40:09 |
Judging History
answer
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#if defined(_WIN32)
#include <windows.h>
#include <psapi.h>
#else
#include "sys/time.h"
#endif
namespace OY {
#define cin OY::inputHelper<1024, 20>::getInstance()
#define getchar() ({char c=cin.getChar_Checked();cin.next();c;})
#define cout OY::outputHelper<1048576>::getInstance()
#define putchar cout.putChar
#define endl '\n'
#define putlog(...) OY::printLog(", ", __VA_ARGS__)
template <uint64_t _BufferSize = 1024, uint64_t _BlockSize = 20>
class inputHelper {
FILE *m_filePtr;
char m_buf[_BufferSize], *m_end, *m_cursor;
bool m_ok;
void flush() {
uint64_t a = m_end - m_cursor;
if (a >= _BlockSize)
return;
memmove(m_buf, m_cursor, a);
uint64_t b = fread(m_buf + a, 1, _BufferSize - a, m_filePtr);
m_cursor = m_buf;
if (a + b < _BufferSize) {
m_end = m_buf + a + b;
*m_end = EOF;
}
}
public:
explicit inputHelper(const char *inputFileName) : m_ok(true) {
if (!*inputFileName)
m_filePtr = stdin;
else
m_filePtr = fopen(inputFileName, "rt");
m_end = m_cursor = m_buf + _BufferSize;
}
~inputHelper() {
fclose(m_filePtr);
}
static inputHelper<_BufferSize, _BlockSize> &getInstance() {
#ifdef OY_LOCAL
static inputHelper<_BufferSize, _BlockSize> s_obj("in.txt");
#else
static inputHelper<_BufferSize, _BlockSize> s_obj("");
#endif
return s_obj;
}
static constexpr bool isBlank(char c) {
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
static constexpr bool isEndline(char c) {
return c == '\n' || c == EOF;
}
const char &getChar_Checked() {
if (m_cursor < m_end)
return *m_cursor;
uint64_t b = fread(m_buf, 1, _BufferSize, m_filePtr);
m_cursor = m_buf;
if (b < _BufferSize) {
m_end = m_buf + b;
*m_end = EOF;
}
return *m_cursor;
}
const char &getChar_Unchecked() const {
return *m_cursor;
}
void next() {
++m_cursor;
}
void setState(bool _ok) {
m_ok = _ok;
}
template <typename _Tp, std::enable_if_t<std::is_signed_v<_Tp> & std::is_integral_v<_Tp>> * = nullptr>
inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {
while (isBlank(getChar_Checked()))
next();
flush();
if (getChar_Unchecked() == '-') {
next();
if (isdigit(getChar_Unchecked())) {
ret = -(getChar_Unchecked() - '0');
while (next(), isdigit(getChar_Unchecked()))
ret = ret * 10 - (getChar_Unchecked() - '0');
} else
m_ok = false;
} else {
if (isdigit(getChar_Unchecked())) {
ret = getChar_Unchecked() - '0';
while (next(), isdigit(getChar_Unchecked()))
ret = ret * 10 + (getChar_Unchecked() - '0');
} else
m_ok = false;
}
return *this;
}
template <typename _Tp, std::enable_if_t<std::is_unsigned_v<_Tp> & std::is_integral_v<_Tp>> * = nullptr>
inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {
while (isBlank(getChar_Checked()))
next();
flush();
if (isdigit(getChar_Unchecked())) {
ret = getChar_Unchecked() - '0';
while (next(), isdigit(getChar_Unchecked()))
ret = ret * 10 + (getChar_Unchecked() - '0');
} else
m_ok = false;
return *this;
}
template <typename _Tp, std::enable_if_t<std::is_floating_point_v<_Tp>> * = nullptr>
inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {
bool neg = false, integer = false, decimal = false;
while (isBlank(getChar_Checked()))
next();
flush();
if (getChar_Unchecked() == '-') {
neg = true;
next();
}
if (!isdigit(getChar_Unchecked()) && getChar_Unchecked() != '.') {
m_ok = false;
return *this;
}
if (isdigit(getChar_Unchecked())) {
integer = true;
ret = getChar_Unchecked() - '0';
while (next(), isdigit(getChar_Unchecked()))
ret = ret * 10 + (getChar_Unchecked() - '0');
}
if (getChar_Unchecked() == '.') {
next();
if (isdigit(getChar_Unchecked())) {
if (!integer)
ret = 0;
decimal = true;
_Tp unit = 0.1;
ret += unit * (getChar_Unchecked() - '0');
while (next(), isdigit(getChar_Unchecked())) {
unit *= 0.1;
ret += unit * (getChar_Unchecked() - '0');
}
}
}
if (!integer && !decimal)
m_ok = false;
else if (neg)
ret = -ret;
return *this;
}
inputHelper<_BufferSize, _BlockSize> &operator>>(char &ret) {
while (isBlank(getChar_Checked()))
next();
ret = getChar_Checked();
next();
return *this;
}
inputHelper<_BufferSize, _BlockSize> &operator>>(std::string &ret) {
while (isBlank(getChar_Checked()))
next();
if (getChar_Checked() != EOF) {
ret.clear();
do {
ret += getChar_Checked();
next();
} while (!isBlank(getChar_Checked()) && getChar_Unchecked() != EOF);
} else
m_ok = false;
return *this;
}
explicit operator bool() {
return m_ok;
}
};
template <uint64_t _BufferSize = 1048576>
class outputHelper {
FILE *m_filePtr = nullptr;
char m_buf[_BufferSize], *m_end, *m_cursor;
char m_tempBuf[50], *m_tempBufCursor, *m_tempBufDot;
uint64_t m_floatReserve, m_floatRatio;
public:
outputHelper(const char *outputFileName, int prec = 6) : m_end(m_buf + _BufferSize) {
if (!*outputFileName)
m_filePtr = stdout;
else
m_filePtr = fopen(outputFileName, "wt");
m_cursor = m_buf;
m_tempBufCursor = m_tempBuf;
precision(prec);
}
static outputHelper<_BufferSize> &getInstance() {
#ifdef OY_LOCAL
static outputHelper<_BufferSize> s_obj("out.txt");
#else
static outputHelper<_BufferSize> s_obj("");
#endif
return s_obj;
}
~outputHelper() {
flush();
fclose(m_filePtr);
}
void precision(int prec) {
m_floatReserve = prec;
m_floatRatio = pow(10, prec);
m_tempBufDot = m_tempBuf + prec;
}
outputHelper<_BufferSize> &flush() {
fwrite(m_buf, 1, m_cursor - m_buf, m_filePtr);
fflush(m_filePtr);
m_cursor = m_buf;
return *this;
}
void putChar(const char &c) {
if (m_cursor == m_end)
flush();
*m_cursor++ = c;
}
void putS(const char *c) {
while (*c)
putChar(*c++);
}
template <typename _Tp, std::enable_if_t<std::is_signed_v<_Tp> & std::is_integral_v<_Tp>> * = nullptr>
outputHelper<_BufferSize> &operator<<(const _Tp &ret) {
_Tp _ret = _Tp(ret);
if (_ret >= 0) {
do {
*m_tempBufCursor++ = '0' + _ret % 10;
_ret /= 10;
} while (_ret);
do
putChar(*--m_tempBufCursor);
while (m_tempBufCursor > m_tempBuf);
} else {
putChar('-');
do {
*m_tempBufCursor++ = '0' - _ret % 10;
_ret /= 10;
} while (_ret);
do
putChar(*--m_tempBufCursor);
while (m_tempBufCursor > m_tempBuf);
}
return *this;
}
template <typename _Tp, std::enable_if_t<std::is_unsigned_v<_Tp> & std::is_integral_v<_Tp>> * = nullptr>
outputHelper<_BufferSize> &operator<<(const _Tp &ret) {
_Tp _ret = _Tp(ret);
do {
*m_tempBufCursor++ = '0' + _ret % 10;
_ret /= 10;
} while (_ret);
do
putChar(*--m_tempBufCursor);
while (m_tempBufCursor > m_tempBuf);
return *this;
}
template <typename _Tp, std::enable_if_t<std::is_floating_point_v<_Tp>> * = nullptr>
outputHelper<_BufferSize> &operator<<(const _Tp &ret) {
if (ret < 0) {
putChar('-');
return *this << -ret;
}
_Tp _ret = ret * m_floatRatio;
uint64_t integer = _ret;
if (_ret - integer >= 0.4999999999)
integer++;
do {
*m_tempBufCursor++ = '0' + integer % 10;
integer /= 10;
} while (integer);
if (m_tempBufCursor > m_tempBufDot) {
do
putChar(*--m_tempBufCursor);
while (m_tempBufCursor > m_tempBufDot);
putChar('.');
} else {
putS("0.");
for (int i = m_tempBufDot - m_tempBufCursor; i--;)
putChar('0');
}
do
putChar(*--m_tempBufCursor);
while (m_tempBufCursor > m_tempBuf);
return *this;
}
outputHelper<_BufferSize> &operator<<(const char &ret) {
putChar(ret);
return *this;
}
outputHelper<_BufferSize> &operator<<(const std::string &ret) {
putS(ret.data());
return *this;
}
};
template <uint64_t _BufferSize, uint64_t _BlockSize>
inputHelper<_BufferSize, _BlockSize> &getline(inputHelper<_BufferSize, _BlockSize> &ih, std::string &ret) {
ret.clear();
if (ih.getChar_Checked() == EOF)
ih.setState(0);
else {
while (!inputHelper<_BufferSize, _BlockSize>::isEndline(ih.getChar_Checked())) {
ret += ih.getChar_Unchecked();
ih.next();
}
ih.next();
}
return ih;
}
template <typename D, typename T, typename... S>
void printLog(D delim, const T &x, S... rest) {
cout << x;
if constexpr(sizeof...(rest) > 0) {
cout << delim;
printLog(delim, rest...);
}
}
}
using OY::getline;
namespace OY {
template <typename _ModType>
struct Barrett {
_ModType m_P;
__uint128_t m_Pinv;
constexpr Barrett() = default;
constexpr explicit Barrett(_ModType __P) : m_P(__P), m_Pinv(-uint64_t(__P) / __P + 1) {}
constexpr _ModType mod() const {
return m_P;
}
constexpr _ModType mod(uint64_t __a) const {
__a -= uint64_t(m_Pinv * __a >> 64) * m_P + m_P;
if (__a >= m_P)
__a += m_P;
return __a;
}
constexpr _ModType raw_mod(uint64_t __a) const {
return __a % m_P;
}
constexpr _ModType multiply(uint64_t __a, uint64_t __b) const {
return mod(__a * __b);
}
constexpr _ModType multiply_128(uint64_t __a, uint64_t __b) const {
if (__builtin_clzll(__a) + __builtin_clzll(__b) >= 64)
return multiply(__a, __b);
return __uint128_t(__a) * __b % m_P;
}
constexpr _ModType multiply_ld(uint64_t __a, uint64_t __b) const {
if (__builtin_clzll(__a) + __builtin_clzll(__b) >= 64)
return multiply(__a, __b);
int64_t res = __a * __b - uint64_t(1.L / m_P * __a * __b) * m_P;
if (res < 0)
res += m_P;
else if (res >= m_P)
res -= m_P;
return res;
}
constexpr _ModType pow(uint64_t __a, uint64_t __n) const {
_ModType res = 1, b = mod(__a);
while (__n) {
if (__n & 1)
res = multiply(res, b);
b = multiply(b, b);
__n >>= 1;
}
return res;
}
constexpr _ModType pow_128(uint64_t __a, uint64_t __n) const {
_ModType res = 1, b = mod(__a);
while (__n) {
if (__n & 1)
res = multiply_128(res, b);
b = multiply_128(b, b);
__n >>= 1;
}
return res;
}
constexpr _ModType pow_ld(uint64_t __a, uint64_t __n) const {
_ModType res = 1, b = mod(__a);
while (__n) {
if (__n & 1)
res = multiply_ld(res, b);
b = multiply_ld(b, b);
__n >>= 1;
}
return res;
}
template <typename _Tp>
constexpr _Tp divide(_Tp __a) const {
if (__a < m_P)
return 0;
_Tp res = m_Pinv * __a >> 64;
if (__a - res * m_P >= m_P)
res++;
return res;
}
template <typename _Tp>
constexpr std::pair<_Tp, _Tp> divmod(_Tp __a) const {
_Tp quo = (__a * m_Pinv) >> 64, rem = __a - quo * m_P;
if (rem >= m_P) {
quo++;
rem -= m_P;
}
return {quo, rem};
}
};
using Barrett32 = Barrett<uint32_t>;
using Barrett64 = Barrett<uint64_t>;
}
namespace OY {
template <typename _ModType>
struct _MontgomeryTag;
template <>
struct _MontgomeryTag<uint32_t> {
using long_type = uint64_t;
static constexpr uint32_t limit = (1073741824u) - 1;
static constexpr uint32_t inv_loop = 4;
static constexpr uint32_t length = 32;
};
template <>
struct _MontgomeryTag<uint64_t> {
using long_type = __uint128_t;
static constexpr uint64_t limit = (1ull << 63) - 1;
static constexpr uint32_t inv_loop = 5;
static constexpr uint32_t length = 64;
};
template <typename _ModType>
struct Montgomery {
using _FastType = _ModType;
using _LongType = typename _MontgomeryTag<_ModType>::long_type;
_ModType m_P;
_ModType m_Pinv;
_ModType m_Ninv;
Barrett<_ModType> m_brt;
constexpr Montgomery() = default;
constexpr explicit Montgomery(_ModType __P) : m_P(__P), m_Pinv(__P), m_Ninv(-_LongType(__P) % __P),
m_brt(__P) {
assert((__P & 1) && __P > 1 && __P <= _MontgomeryTag<_ModType>::limit);
for (uint32_t i = 0; i < _MontgomeryTag<_ModType>::inv_loop; i++)
m_Pinv *= _ModType(2) - __P * m_Pinv;
}
constexpr _ModType mod() const {
return m_brt.mod();
}
constexpr _ModType mod(uint64_t __a) const {
return m_brt.mod(__a);
}
constexpr _ModType raw_mod(uint64_t __a) const {
return m_brt.raw_mod(__a);
}
constexpr _FastType init(uint64_t __a) const {
return reduce(_LongType(mod(__a)) * m_Ninv);
}
constexpr _FastType raw_init(uint64_t __a) const {
return reduce(_LongType(raw_mod(__a)) * m_Ninv);
}
constexpr _FastType reduce(_LongType __a) const {
_FastType res = (__a >> _MontgomeryTag<_ModType>::length) - _ModType(_LongType(_ModType(
__a) * m_Pinv) * m_P >> _MontgomeryTag<_ModType>::length);
if (res >= mod())
res += mod();
return res;
}
constexpr _ModType reduce(_FastType __a) const {
_ModType res = -_ModType(_LongType(__a * m_Pinv) * m_P >> _MontgomeryTag<_ModType>::length);
if (res >= mod())
res += mod();
return res;
}
constexpr _FastType multiply(_FastType __a, _FastType __b) const {
return reduce(_LongType(__a) * __b);
}
constexpr _FastType pow(_FastType __a, uint64_t __n) const {
_FastType res = reduce(_LongType(1) * m_Ninv);
while (__n) {
if (__n & 1)
res = multiply(res, __a);
__a = multiply(__a, __a);
__n >>= 1;
}
return res;
}
template <typename _Tp>
constexpr _Tp divide(_Tp __a) const {
return m_brt.divide(__a);
}
template <typename _Tp>
constexpr std::pair<_Tp, _Tp> divmod(_Tp __a) const {
return m_brt.divmod(__a);
}
};
using Montgomery32 = Montgomery<uint32_t>;
using Montgomery64 = Montgomery<uint64_t>;
}
namespace OY {
template <typename _Elem>
constexpr bool isPrime(_Elem n) {
if (std::is_same_v<_Elem, uint32_t> || n <= UINT32_MAX) {
if (n <= 1)
return false;
if (n == 2 || n == 7 || n == 61)
return true;
if (n % 2 == 0)
return false;
Barrett32 brt(n);
uint32_t d = (n - 1) >> __builtin_ctz(n - 1);
for (auto &&a : {
2, 7, 61
}) {
uint32_t s = d, y = brt.pow(a, s);
while (s != n - 1 && y != 1 && y != n - 1) {
y = brt.multiply(y, y);
s <<= 1;
}
if (y != n - 1 && s % 2 == 0)
return false;
}
return true;
} else {
// assert(n < 1ull < 63);
if (n % 2 == 0)
return false;
Montgomery64 mg(n);
uint64_t d = (n - 1) >> __builtin_ctzll(n - 1), one = mg.init(1);
for (auto &&a : {
2, 325, 9375, 28178, 450775, 9780504, 1795265022
}) {
uint64_t s = d, y = mg.pow(mg.init(a), s), t = mg.init(n - 1);
while (s != n - 1 && y != one && y != t) {
y = mg.multiply(y, y);
s <<= 1;
}
if (y != t && s % 2 == 0)
return false;
}
return true;
}
}
constexpr auto isPrime32 = isPrime<uint32_t>;
constexpr auto isPrime64 = isPrime<uint64_t>;
}
int main() {
uint64_t x;
while (cin >> x && x) {
if (OY::isPrime(x))
cout << "Y";
else
cout << "N";
cout << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 25ms
memory: 3636kb
input:
996581938833575363 971646509461160317 773155992127361153 161603952726515268 540879144500456953 476831214764178553 784255927154201144 671096087619405061 805545190025269709 339546334309245137 337726347922962343 222956293307015293 809183111090275843 799050063298926344 691718101820598109 646220213113313...
output:
N Y Y N Y Y N Y Y Y Y Y Y N Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y N Y Y N Y Y Y Y Y Y Y N Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y ...
result:
ok 15000 lines
Test #2:
score: 0
Accepted
time: 16ms
memory: 3800kb
input:
292094793288448159 456918231632780153 52701684901220791 755430520029564023 202037556396478813 224321375550698537 953758266735232253 68668310674613297 730895589897264853 344428227893888993 521429852982590257 547788290718839273 332181270020381261 876010276438312333 906474115171090099 26200832832269134...
output:
N N Y N N N Y N Y N N N N N Y N Y N Y Y N Y Y N Y N Y N Y N Y N N Y N Y Y Y N N Y N Y Y Y N N N Y N N Y Y N N N N Y N N N N N Y Y N N N N N Y N Y Y Y N N Y N Y N Y N N Y Y N N N N Y Y N Y N N N N Y Y Y N Y N N Y N N Y Y Y Y Y Y Y N Y N N N Y N N N Y N Y N N Y N N N Y Y Y N Y Y Y N Y N N N Y N Y N Y ...
result:
ok 15000 lines
Test #3:
score: 0
Accepted
time: 5ms
memory: 3504kb
input:
37686301288201 83818601792630641 73103085605161 146313732835525609 228087610722516540 343255869017446321 132173451449926849 461798530935794823 171613522570639321 746139393134794441 700705956080852569 186402586980996590 116687280644971921 439801455648601 608187424599317161 582838391995869241 29815648...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #4:
score: 0
Accepted
time: 8ms
memory: 3612kb
input:
37524996401344453 37525085907733993 37525091397104033 37525113078950641 37525124589187073 37525157683455557 37525199043948023 37525222109877577 37525226953298221 37525259363784397 37525364799923431 37525368433484977 37525385480376751 37525430877893551 37525482942628141 37525493960687851 375255005943...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #5:
score: 0
Accepted
time: 9ms
memory: 3552kb
input:
723245739019682401 723245866706340671 723246090945604561 723246352143004873 723246673219734913 723246738513052561 723247420392785287 723247522177775827 723247614067685477 723247698405894889 723247738890989761 723247925881512769 723248063125197301 723248128083366901 723248342755190227 723248614316335...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #6:
score: 0
Accepted
time: 9ms
memory: 3768kb
input:
971250844965384127 971250976411543033 971251162664749381 971251210275610351 971251238585098507 971251326624493501 971252030784923551 971252481632318471 971252499214789069 971252658880954081 971252709089043401 971252873506894229 971252918907625009 971253322904807251 971253706688543701 971254502032321...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #7:
score: 0
Accepted
time: 9ms
memory: 3612kb
input:
975097371418148287 975097379018158177 975098272399702153 975098914621552381 975098941416760309 975098970409909507 975099970219316947 975100563136905217 975100597682316769 975100651225654537 975100655012759497 975101039821060699 975101068247058001 975101132634439177 975101316642410317 975101700693099...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #8:
score: 0
Accepted
time: 9ms
memory: 3832kb
input:
978972814118579281 978972937612021549 978973242843932981 978974480980701913 978974489577710953 978974589631755737 978974652838559653 978974658221459201 978974733332204561 978974806453119673 978975038338417369 978975110530630693 978975222405387461 978975882983990251 978975989516617181 978976060640390...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #9:
score: 0
Accepted
time: 9ms
memory: 3628kb
input:
982815691526899273 982816054071509621 982817060169508141 982817430437283641 982817460181693753 982817461596064513 982817485076790919 982817582130019357 982817899620348031 982818063245540321 982818404515863917 982818922902003769 982818962551574209 982819103882371901 982819366081816363 982819443060395...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #10:
score: 0
Accepted
time: 9ms
memory: 3548kb
input:
986654079350625311 986654424121995397 986654475796632901 986654694060905039 986655094343402881 986655789507565913 986655796720217821 986655894969286081 986656845736427113 986656893630525577 986656899715648481 986656967546105017 986656981419420361 986657020079418001 986657751538639291 986657836955081...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #11:
score: 0
Accepted
time: 9ms
memory: 3608kb
input:
990506396486037061 990506434942654297 990506583343038737 990506633090169007 990506821692002869 990507338152078781 990507642857678513 990509266701009901 990509413103916829 990509672526354901 990509839077929941 990509905448558701 990509948480836033 990509955041980081 990510051552449809 990510327054720...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #12:
score: 0
Accepted
time: 9ms
memory: 3552kb
input:
994436482283245501 994436834643112771 994437438334877633 994438185016980251 994438518667870537 994438572113239849 994439331088447063 994440181755753253 994440412354207381 994440486375543241 994440532681357841 994440572217582901 994440737643657637 994441422312035101 994441492070689121 994441676618381...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #13:
score: 0
Accepted
time: 4ms
memory: 3828kb
input:
998325346159240081 998325547301434393 998326073288529899 998326268408182393 998326321136886799 998326462535387389 998327440063121761 998327468968116311 998327968547706001 998328232689759721 998328353036363983 998328398641461907 998328773289179851 998329620625002751 998329775152828861 998329853754818...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 6507 lines
Test #14:
score: 0
Accepted
time: 5ms
memory: 4000kb
input:
100052803951001600 105728860800000000 893853530276283200 6455400775964240 685235886664718720 793482962376918720 758221361453121056 37589855997724840 1128108118059 895139368646464000 483432966915053800 237004108121200000 22178 645282657277920000 813367395538094000 1136069149644000 281785329587500000 ...
output:
N N N N N N N N N N N N N N N N N N N N N N Y N N N N N N N Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 100000 lines
Test #15:
score: 0
Accepted
time: 3ms
memory: 3832kb
input:
7355283904579708 340900868429664088 409813708555172383 798303077978606212 933070571813959595 847644669042501513 846257476787352 234597331314353867 277585039133688524 851204170596626165 594596242764549240 572350511563954970 192135875262875110 246494444316739512 758894357303160432 816417381374096460 2...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
ok 15000 lines
Test #16:
score: 0
Accepted
time: 25ms
memory: 3596kb
input:
905692770808102913 930028507424096257 949143104756121601 980147206984040449 937502850030764033 995429930529636353 932948810307469313 998400035831171009 975907589757296641 937838365703667713 993888142765326337 952675423299305473 959231186122371073 919613148026621311 915833125114740737 993893747187972...
output:
Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y N N Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y N Y Y N Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y ...
result:
ok 15000 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
output:
N Y Y N Y N Y N N N Y N Y N N N Y N Y N N N Y N N N N N Y N Y N N N N N Y N N N Y N Y N N N Y N N N N N Y N N N N N Y N Y N N N N N Y N N N Y N Y N N N N N Y N N N Y N N N N N Y N N N N N N N Y N N N Y N Y N N N Y N Y N N N Y N N N N N N N N N N N N N Y N N N Y N N N N N Y N Y N N N N N N N N N Y N ...
result:
ok 15000 lines
Test #18:
score: 0
Accepted
time: 4ms
memory: 3636kb
input:
909135097259562682 2 3 5 300914172140004765 27586772282676268 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 891808273166161048 398971097954225213 113 127 131 137 139 149 151 4213617320640392 157 278453033236925382 163 167 173 179 181 712815938968127718 191 193 197 ...
output:
N Y Y Y N N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N N Y Y Y Y Y Y Y N Y N Y Y Y Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y N Y N Y Y Y Y Y Y Y N Y N Y Y Y Y Y Y Y Y Y Y N Y Y N Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y N Y Y Y Y Y Y Y Y ...
result:
ok 15000 lines