結果

問題 No.3708 Uncommon Time
コンテスト
ユーザー kαmμ
提出日時 2026-09-11 21:27:14
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 14,393 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,227 ms
コンパイル使用メモリ 348,228 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-11 21:54:56
合計ジャッジ時間 4,504 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#ifndef KAMMYU_CONSTANTS
#define KAMMYU_CONSTANTS

#include <limits>

namespace kammyu
{
  namespace infinities
  {
    constexpr int inf = std::numeric_limits<int>::max();
    constexpr int _inf = std::numeric_limits<int>::min();
    constexpr long long INF = std::numeric_limits<long long>::max();
    constexpr long long _INF = std::numeric_limits<long long>::min();
  }; // namespace infinities
  namespace modulos
  {
    constexpr int Smod = 998244353;
    constexpr int Bmod = 1000000007;
  }; // namespace modulos
}; // namespace kammyu

#endif // KAMMYU_CONSTANTS

#ifndef KAMMYU_INPUT
#define KAMMYU_INPUT

#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

namespace kammyu
{
  namespace input
  {
    template <typename T1, typename T2>
    std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p)
    {
      return is >> p.first >> p.second;
    }

    template <typename T>
    std::istream& operator>>(std::istream& is, std::vector<T>& v)
    {
      for (T& x : v)
        is >> x;
      return is;
    }

    template <typename T>
    void inp_arr(std::vector<T>& v)
    {
      for (T& i : v)
        std::cin >> i;
    }
    template <typename T1, typename T2>
    void inp_arr(std::vector<T1>& v1, std::vector<T2>& v2)
    {
      for (int i = 0; i < (int)v1.size(); i++)
        std::cin >> v1[i] >> v2[i];
    }
    template <typename T1, typename T2, typename T3>
    void inp_arr(std::vector<T1>& v1, std::vector<T2>& v2, std::vector<T3>& v3)
    {
      for (int i = 0; i < (int)v1.size(); i++)
        std::cin >> v1[i] >> v2[i] >> v3[i];
    }
    template <typename T1, typename T2, typename T3, typename T4>
    void inp_arr(std::vector<T1>& v1, std::vector<T2>& v2, std::vector<T3>& v3, std::vector<T4>& v4)
    {
      for (int i = 0; i < (int)v1.size(); i++)
        std::cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
    }
    template <typename T>
    void inp_arr(std::vector<std::vector<T>>& v)
    {
      for (std::vector<T>& i : v)
        for (T& j : i)
          std::cin >> j;
    }
  }; // namespace input
}; // namespace kammyu

#endif // KAMMYU_INPUT
#ifndef KAMMYU_OUTPUT
#define KAMMYU_OUTPUT

#include <iostream>
#include <ostream>
#include <vector>

namespace kammyu
{
  namespace output
  {
    template <typename T>
    std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<T>>& v)
    {
      for (const std::vector<T>& x : v)
        os << x << "\n";
      return os;
    }
    template <typename T>
    std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
    {
      for (const T& x : v)
        os << x << " ";
      return os;
    }

    void yes(bool o = false)
    {
      if (o)
        std::cout << "Yes";
      else
        std::cout << "Yes" << std::endl;
    }
    void no(bool o = false)
    {
      if (o)
        std::cout << "No";
      else
        std::cout << "No" << std::endl;
    }
    void yn(bool b, bool o = false)
    {
      if (b)
        yes(o);
      else
        no(o);
    }
  }; // namespace output
}; // namespace kammyu

#endif // KAMMYU_OUTPUT

#ifndef KAMMYU_POINT
#define KAMMYU_POINT

#include <iostream>
#include <tuple>
#include <vector>

namespace kammyu
{
  namespace point
  {
    struct P
    {
    private:
      using ll = long long;

    public:
      P() { P(0, 0); }
      P(ll _i, ll _j) : i(_i), j(_j) {}
      ll i, j;
      bool operator==(const P& p) const { return i == p.i && j == p.j; }
      bool operator!=(const P& p) const { return !(*this == p); }
      bool operator<(const P& other) const { return std::tie(i, j) < std::tie(other.i, other.j); }
      bool operator>(const P& other) const { return std::tie(i, j) > std::tie(other.i, other.j); }
      P operator+(const P& other) const { return P(i + other.i, j + other.j); }
      P operator-(const P& other) const { return P(i - other.i, j - other.j); }
      P operator*(const int& other) const { return P(i * other, j * other); }
      P operator*(const ll& other) const { return P(i * other, j * other); }
      P operator*(const P& other) const { return P(i * other.i, j * other.j); }
      P operator*(const double& other) const { return P(i * other, j * other); }
      P operator/(const ll& scaler) const { return P(i / scaler, j / scaler); }
      P operator/(const double& scaler) const { return P(i / scaler, j / scaler); }
      P operator+=(const P& p) { return *this = *this + p; }
      P operator-=(const P& p) { return *this = *this - p; }
      P operator*=(const ll& p) { return *this = *this * p; }
      friend std::ostream& operator<<(std::ostream& os, const P& p) { return os << p.i << " " << p.j; }
      friend std::istream& operator>>(std::istream& is, P& p) { return is >> p.i >> p.j; }
      bool out_of_bounds(ll size) const { return i < 0 || j < 0 || i >= size || j >= size; }
      bool out_of_bounds(ll H, ll W) const { return i < 0 || j < 0 || i >= H || j >= W; }
      P& operator--()
      {
        --i, --j;
        return *this;
      }
      P operator--(int)
      {
        P p = *this;
        --(*this);
        return p;
      }
      void swap()
      {
        std::swap(i, j);
      }
      ll distEucSq() const { return i * i + j * j; }
      ll distManh() const { return i + j; }
    };

    using piP = std::pair<int, P>;
    using pPP = std::pair<P, P>;
    using vP = std::vector<P>;
    using vpiP = std::vector<piP>;
    using vpPP = std::vector<pPP>;
    using vvP = std::vector<std::vector<P>>;
    using vvpiP = std::vector<std::vector<piP>>;
    const vP around4({P(0, 1), P(1, 0), P(0, -1), P(-1, 0)});
    const vP around8({P(0, 1), P(1, 1), P(1, 0), P(1, -1), P(0, -1), P(-1, -1), P(-1, 0), P(-1, 1)});
  }; // namespace point
}; // namespace kammyu

#endif // KAMMYU_POINT

#ifndef KAMMYU_UTILS
#define KAMMYU_UTILS

#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, s, e) for (int i = (s); i < (e); ++i)
#define reep(i, n) for (int i = 0; i <= (n); ++i)
#define reepp(i, s, e) for (int i = (s); i <= (e); ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrepp(i, s, e) for (int i = (e - 1); i >= s; --i)
#define sign(f) (f == 0 ? 0 : ((f) > 0) * 2 - 1)

#define pqueue priority_queue

namespace kammyu
{

  namespace utils
  {
    template <typename T1, typename T2>
    bool chmax(T1& m, const T2& val)
    {
      if (m < val)
      {
        m = val;
        return true;
      }
      return false;
    }
    template <typename T1, typename T2>
    bool chmin(T1& m, const T2& val)
    {
      if (m > val)
      {
        m = val;
        return true;
      }
      return false;
    }

    using ll = long long;
    using pii = std::pair<int, int>;
    using piii = std::pair<int, pii>;
    using si = std::set<int>;
    using vi = std::vector<int>;
    using vpii = std::vector<pii>;
    using vpiii = std::vector<piii>;
    using vvi = std::vector<std::vector<int>>;
    using vvpii = std::vector<std::vector<pii>>;
    using vvvi = std::vector<vvi>;
    using vvvvi = std::vector<vvvi>;

    using vb = std::vector<bool>;
    using vvb = std::vector<vb>;
    using pli = std::pair<ll, int>;
    using plii = std::pair<pli, int>;
    using vpli = std::vector<pli>;
    using vvpli = std::vector<std::vector<pli>>;

    using pll = std::pair<ll, ll>;
    using plll = std::pair<pll, ll>;
    using vl = std::vector<ll>;
    using vpll = std::vector<pll>;
    using vvl = std::vector<std::vector<ll>>;
    using vvpll = std::vector<std::vector<pll>>;
    using vvvl = std::vector<vvl>;
    using vvvvl = std::vector<vvvl>;

    using vsi = std::vector<std::set<int>>;

    using vs = std::vector<std::string>;
    template <typename T>
    using vv = std::vector<std::vector<T>>;

    template <typename T>
    using min_pqueue = std::priority_queue<T, std::vector<T>, std::greater<T>>;
    template <typename T>
    using max_pqueue = std::priority_queue<T>;

    template <typename T1, typename T2>
    std::pair<T1, T2> operator+(const std::pair<T1, T2>& a, const std::pair<T1, T2>& b)
    {
      return std::make_pair(a.first + b.first, a.second + b.second);
    }
    template <typename T1, typename T2>
    std::pair<T1, T2> operator-(const std::pair<T1, T2>& a, const std::pair<T1, T2>& b)
    {
      return std::make_pair(a.first - b.first, a.second - b.second);
    }

    template <typename T>
    void sort(std::vector<T>& v)
    {
      std::sort(all(v));
    }

    vi str2vi(const std::string& s, char first_char = 'a')
    {
      vi res(s.size());
      rep(i, s.size()) res[i] = s[i] - first_char;
      return res;
    }

    template <typename T>
    T sum(const std::vector<T>& vec)
    {
      T res = T();
      for (const T& val : vec)
        res = res + val;
      return res;
    }
    template <typename T>
    T min(const std::vector<T>& vec, T init)
    {
      T res = init;
      for (const T& val : vec)
        if (val < res)
          res = val;
      return res;
    }
    template <typename T>
    T max(const std::vector<T>& vec, T init)
    {
      T res = init;
      for (const T& val : vec)
        if (val > res)
          res = val;
      return res;
    }

  }; // namespace utils
}; // namespace kammyu

#endif // KAMMYU_UTILS


using namespace kammyu::utils;
using namespace kammyu::input;
using namespace kammyu::output;
using namespace kammyu::point;

void MAIN();
int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  MAIN();

  return 0;
}

using namespace std;
void solve();
void precalc();
void MAIN()
{
  precalc();
  int T = 1;
  // cin >> T;
  while (T--)
    solve();

  return;
}

// using namespace kammyu::infinities;
// using namespace kammyu::modulos;
void precalc()
{
  return;
}
#ifndef KAMMYU_NUMTHEOREM_PF
#define KAMMYU_NUMTHEOREM_PF

#include <assert.h>
#include <map>
#include <vector>

namespace kammyu::NumTheorem
{

  namespace __prime
  {
    bool is_prime(unsigned long long val);

    using ll = long long;

    struct PF
    {
    private:
      std::map<ll, int> factors;

    public:
      PF() = default;
      PF(ll n)
      {
        for (ll p = 2; p * p <= n; ++p)
        {
          while (n % p == 0)
          {
            factors[p]++;
            n /= p;
          }
        }
        if (n > 1)
          factors[n]++;
      }
      PF(ll p, int e)
      {
        factors[p] = e;
      }

      ll get() const
      {
        ll res = 1;
        for (const auto& [p, e] : factors)
          for (int i = 0; i < e; ++i)
            res *= p;
        return res;
      }
      const std::map<ll, int>& get_raw() const { return factors; }

      PF& operator*=(const PF& rhs)
      {
        for (const auto& [p, e] : rhs.factors)
          factors[p] += e;
        return *this;
      }
      PF operator*(const PF& rhs) const
      {
        PF res(*this);
        for (const auto& [p, e] : rhs.factors)
          res.factors[p] += e;
        return res;
      }
      PF& div_prime(ll p, bool assertion = true)
      {
        if (assertion)
          assert(is_prime(p));
        factors[p]++;
        return *this;
      }
      PF& prod_prime(ll p, bool assertion = true)
      {
        if (assertion)
          assert(is_prime(p));
        factors[p]++;
        return *this;
      }

      PF& operator/=(const PF& rhs)
      {
        for (const auto& [p, e] : rhs.factors)
          factors[p] -= e;
        return *this;
      }
      PF operator/(const PF& rhs) const
      {
        PF res(*this);
        for (const auto& [p, e] : rhs.factors)
          res.factors[p] -= e;
        return res;
      }

      PF& gcd(const PF& rhs)
      {
        for (const auto& [p, e] : rhs.factors)
          factors[p] = std::min(factors[p], e);
        return *this;
      }
      PF& lcm(const PF& rhs)
      {
        for (const auto& [p, e] : rhs.factors)
          factors[p] = std::max(factors[p], e);
        return *this;
      }

      int count_divisors() const
      {
        int res = 1;
        for (const auto& [p, e] : factors)
          res *= (e + 1);
        return res;
      }

      std::vector<ll> get_divisors() const
      {
        std::vector<ll> res = {1};
        for (const auto& [p, e] : factors)
        {
          int siz = res.size();
          ll cur = 1;
          for (int i = 0; i < e; ++i)
          {
            cur *= p;
            for (int j = 0; j < siz; ++j)
              res.push_back(res[j] * cur);
          }
        }
        return res;
      }
    };

    PF gcd(const PF& a, const PF& b)
    {
      PF res(a);
      return res.gcd(b);
    }
    PF lcm(const PF& a, const PF& b)
    {
      PF res(a);
      return res.lcm(b);
    }

    using ull = unsigned long long;
    __uint128_t pow_mod128(__uint128_t b, ull e, ull m)
    {
      if (m == 0)
        return 0;
      __uint128_t res = 1;
      b %= m;
      while (e)
      {
        if (e & 1)
          res = res * b % m;
        b = b * b % m;
        e >>= 1;
      }
      return res;
    }
    // Miller-Rabin
    bool miller_rabin(ull a, ull N)
    {
      if (a >= N)
        return true;

      ull d = N >> 1;
      ull m1 = d << 1;
      while ((d & 1) == 0)
      {
        if (pow_mod128(a, d, N) == m1)
          return true;
        d >>= 1;
      }

      ull _ = pow_mod128(a, d, N);
      return _ == 1 || _ == m1;
    }
    bool is_prime(ull val)
    {
      if (val <= 2)
        return val == 2;
      if ((val & 1) == 0)
        return false;

      if (val < 4759123141ull)
        return miller_rabin(2, val) &&
               miller_rabin(7, val) &&
               miller_rabin(61, val);

      return miller_rabin(2, val) &&
             miller_rabin(325, val) &&
             miller_rabin(9375, val) &&
             miller_rabin(28178, val) &&
             miller_rabin(450775, val) &&
             miller_rabin(9780504, val) &&
             miller_rabin(1795265022, val);
    }

  } // namespace __prime

  using __prime::PF;

  using __prime::gcd;

  using __prime::lcm;

  using __prime::is_prime;

} // namespace kammyu::NumTheorem

#endif // KAMMYU_NUMTHEOREM_PF

void solve()
{
  int M, D;
  cin >> M >> D;

  yn(kammyu::NumTheorem::is_prime(M * 100 + D));
  return;
}

0