結果

問題 No.941 商とあまり
ユーザー PachicobuePachicobue
提出日時 2019-12-04 18:08:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 20,662 bytes
コンパイル時間 3,602 ms
コンパイル使用メモリ 234,112 KB
実行使用メモリ 13,500 KB
最終ジャッジ日時 2024-05-08 04:43:10
合計ジャッジ時間 15,354 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
6,940 KB
testcase_13 AC 27 ms
6,944 KB
testcase_14 AC 26 ms
6,940 KB
testcase_15 WA -
testcase_16 RE -
testcase_17 AC 95 ms
11,836 KB
testcase_18 AC 82 ms
11,832 KB
testcase_19 AC 83 ms
13,112 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 26 ms
6,944 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 27 ms
6,944 KB
testcase_32 AC 35 ms
6,940 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 82 ms
12,728 KB
testcase_35 AC 79 ms
12,344 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 75 ms
11,448 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 3 ms
6,944 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 RE -
testcase_46 WA -
testcase_47 AC 26 ms
6,940 KB
testcase_48 AC 3 ms
6,944 KB
testcase_49 RE -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 78 ms
12,600 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 RE -
testcase_57 AC 81 ms
11,316 KB
testcase_58 AC 81 ms
11,960 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 27 ms
6,944 KB
testcase_62 AC 75 ms
12,344 KB
testcase_63 AC 75 ms
12,472 KB
testcase_64 AC 78 ms
11,580 KB
testcase_65 AC 78 ms
11,960 KB
testcase_66 WA -
testcase_67 AC 76 ms
11,964 KB
testcase_68 WA -
testcase_69 AC 80 ms
12,476 KB
testcase_70 AC 78 ms
11,576 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 AC 78 ms
12,732 KB
testcase_74 AC 84 ms
11,704 KB
testcase_75 AC 79 ms
11,832 KB
testcase_76 AC 81 ms
11,964 KB
testcase_77 AC 82 ms
12,728 KB
testcase_78 AC 80 ms
12,600 KB
testcase_79 AC 82 ms
12,344 KB
testcase_80 AC 80 ms
12,984 KB
testcase_81 AC 81 ms
12,600 KB
testcase_82 AC 78 ms
11,576 KB
testcase_83 AC 79 ms
12,988 KB
testcase_84 AC 80 ms
12,348 KB
testcase_85 AC 81 ms
11,576 KB
testcase_86 AC 82 ms
11,580 KB
testcase_87 AC 80 ms
12,220 KB
testcase_88 AC 84 ms
12,088 KB
testcase_89 AC 82 ms
11,708 KB
testcase_90 AC 81 ms
12,860 KB
testcase_91 AC 86 ms
11,576 KB
testcase_92 AC 81 ms
11,448 KB
testcase_93 AC 80 ms
12,856 KB
testcase_94 AC 89 ms
11,704 KB
testcase_95 AC 80 ms
11,960 KB
testcase_96 AC 80 ms
12,732 KB
testcase_97 AC 83 ms
13,112 KB
testcase_98 AC 2 ms
6,940 KB
testcase_99 AC 78 ms
12,216 KB
testcase_100 AC 84 ms
12,604 KB
testcase_101 AC 3 ms
6,940 KB
testcase_102 AC 2 ms
6,940 KB
testcase_103 AC 79 ms
11,448 KB
testcase_104 AC 2 ms
6,944 KB
testcase_105 AC 2 ms
6,940 KB
testcase_106 WA -
testcase_107 AC 2 ms
6,944 KB
testcase_108 AC 2 ms
6,940 KB
testcase_109 AC 29 ms
8,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// created [2019/12/03] 23:59:35
#pragma GCC optimize("Ofast")
//#pragma GCC target("tune=native")
#pragma GCC target("avx")
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-conversion"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using uint = unsigned int;
using usize = std::size_t;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T msbp1(const T u) { return log2p1(u); }
template<typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); }
template<typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); }
template<typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; }
template<typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); }
template<typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); }
template<typename T> constexpr bool btest(const T mask, const usize ind) { return static_cast<bool>((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); }
template<typename T> void bset(T& mask, const usize ind) { mask |= (static_cast<T>(1) << ind); }
template<typename T> void breset(T& mask, const usize ind) { mask &= ~(static_cast<T>(1) << ind); }
template<typename T> void bflip(T& mask, const usize ind) { mask ^= (static_cast<T>(1) << ind); }
template<typename T> void bset(T& mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); }
template<typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); }
template<typename T> bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); }
template<typename T> bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); }
constexpr unsigned int mod                  = 1000000007;
template<typename T> constexpr T inf_v      = std::numeric_limits<T>::max() / 4;
template<typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884};

template<typename T>
T read()
{
    T v;
    return std::cin >> v, v;
}
template<typename T, typename... Args>
auto read(const usize size, Args... args)
{
    std::vector<decltype(read<T>(args...))> ans(size);
    for (usize i = 0; i < size; i++) { ans[i] = read<T>(args...); }
    return ans;
}
template<typename... Types>
auto reads() { return std::tuple<std::decay_t<Types>...>{read<Types>()...}; }
#    define SHOW(...) static_cast<void>(0)
constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; }

template<typename T>
std::vector<T> make_v(const usize size, const T v) { return std::vector<T>(size, v); }
template<typename... Args>
auto make_v(const usize size, Args... args) { return std::vector<decltype(make_v(args...))>(size, make_v(args...)); }


template<typename T> T gcd(const T& a, const T& b) { return a < 0 ? gcd(-a, b) : b < 0 ? gcd(a, -b) : (a > b ? gcd(b, a) : a == 0 ? b : gcd(b % a, a)); }
template<typename T> T lcm(const T& a, const T& b) { return a / gcd(a, b) * b; }
template<typename T>
constexpr std::pair<T, T> extgcd(const T a, const T b)
{
    if (b == 0) { return std::pair<T, T>{1, 0}; }
    const auto g = gcd(a, b), da = std::abs(b) / g;
    const auto p = extgcd(b, a % b);
    const auto x = (da + p.second % da) % da, y = (g - a * x) / b;
    return {x, y};
}
template<typename T>
constexpr T inverse(const T a, const T mod) { return extgcd(a, mod).first; }
template<uint mod_value, bool dynamic = false>
class modint_base
{
public:
    template<typename UInt = uint>
    static std::enable_if_t<dynamic, const UInt> mod() { return mod_ref(); }
    template<typename UInt = uint>
    static constexpr std::enable_if_t<not dynamic, const UInt> mod() { return mod_value; }
    template<typename UInt = uint>
    static void set_mod(const std::enable_if_t<dynamic, const UInt> mod) { mod_ref() = mod, inv_ref() = {1, 1}; }
    modint_base() : v{0} {}
    modint_base(const ll val) : v{norm(static_cast<uint>(val % static_cast<ll>(mod()) + static_cast<ll>(mod())))} {}
    modint_base(const modint_base& n) : v{n()} {}
    explicit operator bool() const { return v != 0; }
    bool operator!() const { return not static_cast<bool>(*this); }
    modint_base& operator=(const modint_base& m) { return v = m(), (*this); }
    modint_base& operator=(const ll val) { return v = norm(uint(val % static_cast<ll>(mod()) + static_cast<ll>(mod()))), (*this); }
    friend modint_base operator+(const modint_base& m) { return m; }
    friend modint_base operator-(const modint_base& m) { return make(norm(mod() - m.v)); }
    friend modint_base operator+(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + m2.v)); }
    friend modint_base operator-(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + mod() - m2.v)); }
    friend modint_base operator*(const modint_base& m1, const modint_base& m2) { return make(static_cast<uint>(static_cast<ll>(m1.v) * static_cast<ll>(m2.v) % static_cast<ll>(mod()))); }
    friend modint_base operator/(const modint_base& m1, const modint_base& m2) { return m1 * inv(m2.v); }
    friend modint_base operator+(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) + val}; }
    friend modint_base operator-(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) - val}; }
    friend modint_base operator*(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) * (val % static_cast<ll>(mod()))}; }
    friend modint_base operator/(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) * inv(val)}; }
    friend modint_base operator+(const ll val, const modint_base& m) { return modint_base{static_cast<ll>(m.v) + val}; }
    friend modint_base operator-(const ll val, const modint_base& m) { return modint_base{-static_cast<ll>(m.v) + val}; }
    friend modint_base operator*(const ll val, const modint_base& m) { return modint_base{static_cast<ll>(m.v) * (val % static_cast<ll>(mod()))}; }
    friend modint_base operator/(const ll val, const modint_base& m) { return modint_base{val * inv(static_cast<ll>(m.v))}; }
    friend modint_base& operator+=(modint_base& m1, const modint_base& m2) { return m1 = m1 + m2; }
    friend modint_base& operator-=(modint_base& m1, const modint_base& m2) { return m1 = m1 - m2; }
    friend modint_base& operator*=(modint_base& m1, const modint_base& m2) { return m1 = m1 * m2; }
    friend modint_base& operator/=(modint_base& m1, const modint_base& m2) { return m1 = m1 / m2; }
    friend modint_base& operator+=(modint_base& m, const ll val) { return m = m + val; }
    friend modint_base& operator-=(modint_base& m, const ll val) { return m = m - val; }
    friend modint_base& operator*=(modint_base& m, const ll val) { return m = m * val; }
    friend modint_base& operator/=(modint_base& m, const ll val) { return m = m / val; }
    friend modint_base operator^(const modint_base& m, const ll n) { return power(m.v, n); }
    friend modint_base& operator^=(modint_base& m, const ll n) { return m = m ^ n; }
    friend bool operator==(const modint_base& m1, const modint_base& m2) { return m1.v == m2.v; }
    friend bool operator!=(const modint_base& m1, const modint_base& m2) { return not(m1 == m2); }
    friend bool operator==(const modint_base& m, const ll val) { return m.v == norm(static_cast<uint>(static_cast<ll>(mod()) + val % static_cast<ll>(mod()))); }
    friend bool operator!=(const modint_base& m, const ll val) { return not(m == val); }
    friend bool operator==(const ll val, const modint_base& m) { return m.v == norm(static_cast<uint>(static_cast<ll>(mod()) + val % static_cast<ll>(mod()))); }
    friend bool operator!=(const ll val, const modint_base& m) { return not(m == val); }
    friend std::istream& operator>>(std::istream& is, modint_base& m)
    {
        ll v;
        return is >> v, m = v, is;
    }
    friend std::ostream& operator<<(std::ostream& os, const modint_base& m) { return os << m(); }
    uint operator()() const { return v; }
    static modint_base small_inv(const usize n)
    {
        auto& in = inv_ref();
        if (n < in.size()) { return in[n]; }
        for (usize i = in.size(); i <= n; i++) { in.push_back(-in[modint_base::mod() % i] * (modint_base::mod() / i)); }
        return in.back();
    }

private:
    template<typename UInt = uint>
    static std::enable_if_t<dynamic, UInt&> mod_ref()
    {
        static UInt mod = 0;
        return mod;
    }
    static uint norm(const uint x) { return x < mod() ? x : x - mod(); }
    static modint_base make(const uint x)
    {
        modint_base m;
        return m.v = x, m;
    }
    static modint_base power(modint_base x, ull n)
    {
        modint_base ans = 1;
        for (; n; n >>= 1, x *= x) {
            if (n & 1) { ans *= x; }
        }
        return ans;
    }
    static modint_base inv(const ll v) { return v < 2000000 ? small_inv(static_cast<usize>(v)) : modint_base{inverse(v, static_cast<ll>(mod()))}; }
    //    static modint_base inv(const ll v) { return modint_base{inverse(v, static_cast<ll>(mod()))}; }
    static std::vector<modint_base>& inv_ref()
    {
        static std::vector<modint_base> in{1, 1};
        return in;
    }
    uint v;
};
template<uint mod>
using modint = modint_base<mod, false>;
template<uint id>
using dynamic_modint = modint_base<id, true>;


/**
 * http://xoshiro.di.unimi.it/xoshiro128starstar.c
 * http://xoshiro.di.unimi.it/xoshiro256starstar.c
 * http://xoshiro.di.unimi.it/splitmix64.c
 */
class xoshiro
{
public:
    using result_type = uint32_t;
    static constexpr result_type min() { return std::numeric_limits<result_type>::min(); }
    static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
    xoshiro() : xoshiro(std::random_device{}()) {}
    xoshiro(uint64_t seed)
    {
        uint64_t z = 0;
        for (int i = 0; i < 4; i++) { z = (seed += 0x9e3779b97f4a7c15), z = (z ^ (z >> 33)) * 0x62A9D9ED799705F5, z = (z ^ (z >> 28)) * 0xCB24D0A5C88C35B3, s[i] = static_cast<result_type>(z >> 32); }
    }
    result_type operator()()
    {
        const result_type result = rotl(s[1] * 5, 7) * 9, t = s[1] << 9;
        return s[2] ^= s[0], s[3] ^= s[1], s[1] ^= s[2], s[0] ^= s[3], s[2] ^= t, s[3] = rotl(s[3], 11), result;
    }
    void discard(const usize rep)
    {
        for (usize i = 0; i < rep; i++) { (*this)(); }
    }

private:
    result_type s[4];
    static result_type rotl(const result_type x, const int k) { return (x << k) | (x >> (32 - k)); }
};
class xoshiro_64
{
public:
    using result_type = uint64_t;
    static constexpr result_type min() { return std::numeric_limits<result_type>::min(); }
    static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
    xoshiro_64() : xoshiro_64(std::random_device{}()) {}
    xoshiro_64(uint64_t seed)
    {
        uint64_t z = 0;
        for (int i = 0; i < 4; i++) { z = (seed += 0x9e3779b97f4a7c15), z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9, z = (z ^ (z >> 27)) * 0x94d049bb133111eb, s[i] = static_cast<result_type>(z ^ (z >> 31)); }
    }
    result_type operator()()
    {
        const result_type result = rotl(s[1] * 5, 7) * 9, t = s[1] << 17;
        return s[2] ^= s[0], s[3] ^= s[1], s[1] ^= s[2], s[0] ^= s[3], s[2] ^= t, s[3] = rotl(s[3], 45), result;
    }
    void discard(const usize rep)
    {
        for (usize i = 0; i < rep; i++) { (*this)(); }
    }

private:
    result_type s[4];
    static result_type rotl(const result_type x, const int k) { return (x << k) | (x >> (64 - k)); }
};
template<typename Rng>
class rng_base
{
public:
    using rng_type    = Rng;
    using result_type = typename rng_type::result_type;
    static constexpr result_type min() { return rng_type::min(); }
    static constexpr result_type max() { return rng_type::max(); }
    rng_base() : rng_base(std::random_device{}()) {}
    rng_base(const u64 seed) : rng(seed) {}
    ~rng_base() = default;
    result_type operator()(const result_type max = std::numeric_limits<result_type>::max())
    {
        if (max == std::numeric_limits<result_type>::max()) { return static_cast<result_type>(rng()); }
        if (ispow2(max + 1)) { return static_cast<result_type>(rng() & max); }
        const result_type mask = static_cast<result_type>(ceil2(static_cast<u64>(max + 1))) - 1;
        while (true) {
            const result_type ans = static_cast<result_type>(rng() & mask);
            if (ans <= max) { return ans; }
        }
    }
    result_type operator()(const result_type min, const result_type max) { return min + (*this)(max - min); }
    operator bool() { return *this(0, 1); }
    template<typename Int> std::pair<Int, Int> pair(const Int min, const Int max, const bool sorted = false) { return sorted ? std::minmax(*this(min, max), *this(min, max)) : std::pair<Int, Int>{*this(min, max), *this(min, max)}; }
    template<typename Int>
    std::vector<Int> vec(const std::size_t size, const Int min, const Int max)
    {
        std::vector<Int> v(size);
        for (std::size_t i = 0; i < size; i++) { v[i] = *this(min, max); }
        return v;
    }
    std::vector<usize> perm(const usize n)
    {
        std::vector<usize> ans(n);
        std::iota(ans.begin(), ans.end(), 0UL);
        std::shuffle(ans.begin(), ans.end(), rng);
        return ans;
    }

private:
    Rng rng;
};
using rng_mt        = rng_base<std::mt19937>;
using rng_mt64      = rng_base<std::mt19937_64>;
using rng_xoshiro   = rng_base<xoshiro>;
using rng_xoshiro64 = rng_base<xoshiro_64>;
rng_mt g_rng_mt;
rng_mt64 g_rng_mt64;
rng_xoshiro g_rng_xo;
rng_xoshiro64 g_rng_xo64;
class stopwatch
{
public:
    stopwatch() : start{std::chrono::system_clock::now()}, rap_point{start} {}
    template<typename Duration = std::chrono::milliseconds>
    int64_t rap()
    {
        const auto now   = std::chrono::system_clock::now();
        const auto cnt   = std::chrono::duration_cast<Duration>(now - rap_point).count();
        return rap_point = now, cnt;
    }
    template<typename Duration = std::chrono::milliseconds>
    int64_t total()
    {
        const auto now = std::chrono::system_clock::now();
        const auto cnt = std::chrono::duration_cast<Duration>(now - start).count();
        return cnt;
    }

private:
    std::chrono::system_clock::time_point start;
    std::chrono::system_clock::time_point rap_point;
};
int main()
{
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false);
    const int N = read<int>();
    const ull X = read<ull>();
    auto A      = read<ull>(N);
    // stopwatch sw;
    std::sort(A.begin(), A.end());
    {
        ull x = X + 1;
        for (const ull a : A) { x /= (a + 1); }
        if (x == 0) { return std::cout << std::string(X, '0') << std::endl, 0; }
    }
    {
        std::set<ull> kind;
        ull p = 1;
        for (const ull a : A) {
            kind.insert(a);
            p *= (a + 1);
        }
        p--;
        if (kind.size() == 1) {
            const ull x = *kind.begin();
            std::vector<bool> ok(X + 1, false);
            for (ull q = p; q <= X; q += x) {
                ok[q] = true;
            }
            for (int i = 1; i <= X; i++) { std::cout << ok[i]; }
            std::cout << std::endl;
            return 0;
        }
    }
    {
        if (N == 1) {
            std::string ans(X, '0');
            ans[A[0] - 1] = '1';
            return std::cout << ans << std::endl, 0;
        }
    }
    {
        if (N == 2) {
            ull p = 1;
            for (const ull a : A) { p *= (a + 1); }
            p--;
            for (ull i = 1; i <= X; i++) {
                if (i < p) {
                    std::cout << 0;
                } else {
                    const ull y = i - p;
                    std::cout << (y % A[0] == 0 or y % A[1] == 0);
                }
            }
            std::cout << std::endl;
            return 0;
        }
    }
    //    std::cerr << sw.rap() << "ms" << std::endl;
    constexpr uint mod = 1000117;  //???
    using mint         = modint<mod>;
    std::vector<mint> hs(X + 1), ihs(X + 1, 1);
    for (int i = 0; i <= X; i++) { hs[i] = g_rng_xo(2, mod - 2), ihs[i] /= hs[i]; }
    // std::cerr << sw.rap() << "ms" << std::endl;
    constexpr ull NONE = 1ULL << 60;
    std::vector<ull> v = A;
    mint hash          = 1;
    for (const ull a : A) { hash *= hs[a]; }
    ull product = 1;
    for (const ull a : A) { product *= (a + 1); }
    int size = N;
    std::vector<int> is(N);
    ull L = 1;
    for (const ull a : A) { L *= a; }
    L = std::min(L + product - 1, X);
    // const ull L = std::min(std::accumulate(A.begin(), A.end(), 0ULL) + product - 1, X);
    // const ull L       = product - 1;
    auto make_inds_of = [&](const std::vector<ull>& v) {
        size = 0;
        for (int i = 0; i < N; i++) {
            if (v[i] == NONE) { continue; }
            is[size++] = i;
        }
    };

    std::vector<bool> ok(X + 1, false);
    for (const ull a : A) {
        for (ull z = product - 1; z <= X; z += a) { ok[z] = true; }
    }
    auto in = [&](const int i, const int j, const ull /*x*/, const ull /*y*/, const ull z, const ull next_product, const mint& next_hash) {
        v[i] = z, v[j] = NONE;
        product = next_product;
        hash    = next_hash;
    };
    auto out = [&](const int i, const int j, const ull x, const ull y, const ull /*z*/, const ull new_product, const mint& new_hash) {
        v[i] = x, v[j] = y;
        product = new_product;
        hash    = new_hash;
    };

    std::set<uint> used_hash;
    used_hash.insert(hash());
    std::set<uint> used_new_hash;
    // std::cerr << sw.rap() << "ms" << std::endl;
    auto dfs = [&](auto&& self) -> void {
        SHOW(v);
        make_inds_of(v);
        if (size == 2) {
            const ull x = v[is[0]], y = v[is[1]];
            const ull new_value = (x + 1) * (y + 1) - 1;
            for (ull z = new_value;; z += x) {
                if (z > L) { break; }
                ok[z] = true;
            }
            for (ull z = new_value + y;; z += y) {
                if (z > L) { break; }
                ok[z] = true;
            }
            return;
        }
        for (int i_ = 0; i_ < size; i_++) {
            for (int j_ = i_ + 1; j_ < size; j_++) {
                const int i = is[i_], j = is[j_];
                const ull x = v[i], y = v[j];
                const mint new_hash = hash * ihs[x] * ihs[y];
                if (used_new_hash.find(new_hash()) != used_new_hash.end()) { continue; }
                used_new_hash.insert(new_hash());
                const ull new_product = product / (x + 1) / (y + 1);
                const ull new_value   = (x + 1) * (y + 1) - 1;
                for (ull z = new_value;; z += x) {
                    ull next_product = new_product * (z + 1);
                    if (next_product > L + 1) { break; }
                    mint next_hash = new_hash * hs[z];
                    if (used_hash.find(next_hash()) != used_hash.end()) { continue; }
                    used_hash.insert(next_hash());
                    in(i, j, x, y, z, next_product, next_hash);
                    self(self);
                    out(i, j, x, y, z, new_product, new_hash);
                }
                for (ull z = new_value + y;; z += y) {
                    ull next_product = new_product * (z + 1);
                    if (next_product > L + 1) { break; }
                    mint next_hash = new_hash * hs[z];
                    if (used_hash.find(next_hash()) != used_hash.end()) { continue; }
                    used_hash.insert(next_hash());
                    in(i, j, x, y, z, next_product, next_hash);
                    self(self);
                    out(i, j, x, y, z, new_product, new_hash);
                }
            }
        }
    };
    dfs(dfs);
    // std::cerr << sw.rap() << "ms" << std::endl;
    std::cerr << used_hash.size() << std::endl;
    for (int x = 1; x <= X; x++) {
        if (x <= L) {
            std::cout << ok[x];
        } else {
            std::cout << 1;
        }
    }
    std::cout << std::endl;
    return 0;
}
0