結果

問題 No.826 連絡網
ユーザー stoqstoq
提出日時 2020-12-17 02:44:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 739 ms / 2,000 ms
コード長 3,246 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 216,884 KB
実行使用メモリ 161,704 KB
最終ジャッジ日時 2023-10-20 10:32:20
合計ジャッジ時間 27,689 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 723 ms
159,968 KB
testcase_01 AC 728 ms
159,968 KB
testcase_02 AC 724 ms
159,972 KB
testcase_03 AC 714 ms
159,988 KB
testcase_04 AC 721 ms
159,992 KB
testcase_05 AC 718 ms
159,980 KB
testcase_06 AC 713 ms
159,980 KB
testcase_07 AC 708 ms
159,992 KB
testcase_08 AC 714 ms
159,980 KB
testcase_09 AC 713 ms
159,992 KB
testcase_10 AC 710 ms
159,976 KB
testcase_11 AC 720 ms
159,984 KB
testcase_12 AC 726 ms
161,256 KB
testcase_13 AC 720 ms
160,516 KB
testcase_14 AC 718 ms
160,952 KB
testcase_15 AC 726 ms
160,108 KB
testcase_16 AC 725 ms
160,648 KB
testcase_17 AC 722 ms
160,520 KB
testcase_18 AC 714 ms
160,408 KB
testcase_19 AC 734 ms
161,440 KB
testcase_20 AC 734 ms
161,420 KB
testcase_21 AC 711 ms
160,000 KB
testcase_22 AC 720 ms
160,528 KB
testcase_23 AC 717 ms
160,668 KB
testcase_24 AC 718 ms
160,296 KB
testcase_25 AC 729 ms
161,696 KB
testcase_26 AC 732 ms
160,356 KB
testcase_27 AC 739 ms
161,296 KB
testcase_28 AC 731 ms
161,012 KB
testcase_29 AC 725 ms
160,512 KB
testcase_30 AC 736 ms
161,704 KB
testcase_31 AC 732 ms
160,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MOD_TYPE 2

#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif
#if 1
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-7;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct io_init
{
  io_init()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} io_init;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

const int MAX_N = 2e7;
ll can_div[MAX_N] = {};

void init_prime()
{
  can_div[1] = -1;
  for (ll i = 2; i < MAX_N; i++)
  {
    if (can_div[i] != 0)
      continue;
    for (ll j = i + i; j < MAX_N; j += i)
      can_div[j] = i;
  }
}

inline bool is_prime(ll n)
{
  if (n <= 1)
    return false;
  return !can_div[n];
}

void factorization(int n, unordered_map<ll, int> &res)
{
  if (n <= 1)
    return;
  if (!can_div[n])
  {
    ++res[n];
    return;
  }
  ++res[can_div[n]];
  factorization(n / can_div[n], res);
}

void solve()
{
  init_prime();
  int n, p;
  cin >> n >> p;
  set<int> st;
  st.insert(1);
  for (int i = 2; i <= n; i++)
  {
    if (is_prime(i) and 2 * i > n)
      st.insert(i);
  }  
  if (st.count(p))
    cout << 1 << "\n";
  else
    cout << n - st.size() << "\n";
}

int main()
{
  solve();
}
0