結果

問題 No.2592 おでぶなおばけさん 2
ユーザー MisukiMisuki
提出日時 2024-02-08 22:01:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 5,251 bytes
コンパイル時間 4,731 ms
コンパイル使用メモリ 215,092 KB
実行使用メモリ 814,556 KB
最終ジャッジ日時 2024-02-08 22:01:45
合計ジャッジ時間 13,991 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O2")
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <compare>
#include <complex>
#include <concepts>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numbers>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>

#define int ll
#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)
#define INT128_MIN (-INT128_MAX - 1)

#define clock chrono::steady_clock::now().time_since_epoch().count()

#ifdef DEBUG
#define dbg(x) cout << (#x) << " = " << x << '\n'
#else
#define dbg(x)
#endif

namespace R = std::ranges;
namespace V = std::views;

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
//#define double ldb

template<class T>
ostream& operator<<(ostream& os, const pair<T, T> pr) {
  return os << pr.first << ' ' << pr.second;
}
template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &arr) {
  for(const T &X : arr)
    os << X << ' ';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec) {
  for(const T &X : vec)
    os << X << ' ';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const set<T> &s) {
  for(const T &x : s)
    os << x << ' ';
  return os;
}

//note: inversion only works when MOD is a prime

struct mint {
  static long long MOD;
  long long _val;

  mint(long long init = 0) {
    _val = init % MOD;
    (*this).norm();
  }

  mint POW(long long index) {
    if (index == 0)
      return mint(1ll);
    mint base = *this;
    mint res = (base == 0ll ? 0ll : 1ll);
    while(index) {
      if (index & 1)
        res *= base;
      base *= base, index >>= 1;
    }
    return res;
  }

  mint inv() { return (*this).POW(MOD - 2); }

  mint& norm() {
    if (_val >= MOD)
      _val -= MOD;
    if (_val < 0)
      _val += MOD;
    return *this;
  }

  mint& operator+=(mint b) {
    _val += b._val;
    return (*this).norm();
  }
  mint& operator-=(mint b) {
    _val -= b._val;
    return (*this).norm();
  }
  mint& operator*=(mint b) {
    _val = (_val * b._val) % MOD;
    return *this;
  }
  mint& operator/=(mint b) {
    _val = (_val * b.inv()._val) % MOD;
    return *this;
  }

  mint& operator++() {
    _val += 1;
    return (*this).norm();
  }
  mint& operator--() {
    _val -= 1;
    return (*this).norm();
  }
  mint operator++(signed) {
    mint tmp = *this;
    ++(*this);
    return tmp;
  }
  mint operator--(signed) {
    mint tmp = *this;
    --(*this);
    return tmp;
  }

  mint operator-() { return mint(-_val); }
  bool operator==(mint b) { return _val == b._val; }
  bool operator!=(mint b) { return _val != b._val; }
  
  friend mint operator+(mint a, mint b) { return a += b; }
  friend mint operator-(mint a, mint b) { return a -= b; }
  friend mint operator*(mint a, mint b) { return a *= b; }
  friend mint operator/(mint a, mint b) { return a /= b; }

  friend ostream& operator<<(ostream& os, const mint& b) {
    return os << b._val;
  }
  friend istream& operator>>(istream& is, mint& b) {
    long long val;
    is >> val;
    b = mint(val);
    return is;
  }
};

ll mint::MOD = 2;

const int C = 100000001;
vector<int> prime;
int mpf[C];
void sieve() {
  for(int i = 1; i < C; i++)
    mpf[i] = i;
  for(int i = 2; i < C; i++) {
    if (mpf[i] == i)
      prime.emplace_back(i);
    for(int P : prime) {
      if (P > mpf[i] or i * P >= C)
        break;
      mpf[i * P] = P;
    }
  }
}

vector<pii> factorize(int val) {
  vector<pii> res;
  while(val > 1) {
    int p = mpf[val];
    res.emplace_back(p, 0);
    while(val % p == 0)
      res.back().second += 1, val /= p;
  }
  return res;
}

vector<int> factors(int val) {
  vector<int> res(1, 1);
  for(auto [p, idx] : factorize(val)) {
    vector<int> tmp;
    for(int i = 0, base = 1; i <= idx; i++, base *= p)
      for(int X : res)
        tmp.emplace_back(X * base);
    res.swap(tmp);
  }
  return res;
}

mt19937 rng(clock);
uniform_int_distribution<int> unif(5000000, 5761454);

signed main() {
  ios::sync_with_stdio(false), cin.tie(NULL);

  sieve();

  int n, q, k; cin >> n >> q >> k;
  while(k % (mint::MOD = unif(rng)) == 0);
  dbg(mint::MOD);
  vector<mint> a(n + 1);
  for(mint &x : a | V::drop(1))
    cin >> x;

  mint tmp = k;
  for(int i = 1; i <= n; i++)
    a[i] *= tmp, tmp *= k;

  partial_sum(a.begin(), a.end(), a.begin());

  while(q--) {
    int l, r; cin >> l >> r;
    cout << (a[r] - a[l - 1] == 0 ? "No\n" : "Yes\n");
  }

  return 0;
}
0