結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー KAM1KAZEKAM1KAZE
提出日時 2024-01-29 14:19:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 3,873 bytes
コンパイル時間 5,352 ms
コンパイル使用メモリ 264,416 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-29 14:19:41
合計ジャッジ時間 6,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include("atcoder/all")
#include <atcoder/all>
using namespace atcoder;
#endif

#define int long long
#define rep1(a) for (int i = 0; i < a; i++)
#define rep2(i, a) for (int i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)

#define fore(i, a) for (auto &i : a)
#define all(n) n.begin(), n.end()
#define pb push_back
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define SIZE(c) (int)(c).size()
#ifndef _LOCAL
#pragma GCC optimize("-O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#endif

#define ryes return yes();
#define rno return no();
template <class T>
pair<T, T> operator-(const pair<T, T> &x, const pair<T, T> &y) {
  return pair<T, T>(x.fi - y.fi, x.se - y.se);
}
template <class T>
pair<T, T> operator+(const pair<T, T> &x, const pair<T, T> &y) {
  return pair<T, T>(x.fi + y.fi, x.se + y.se);
}
template <class T, class S>
ostream &operator<<(ostream &os, const pair<T, S> &p) {
  os << "(" << p.first << ", " << p.second << ")" << endl;
  return os;
}

inline void yes() { cout << "Yes" << endl; }
inline void no() { cout << "No" << endl; }
inline void yneos(bool f) {
  if (f)
    yes();
  else
    no();
}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

/*vector input*/
template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v)
    is >> e;
  return is;
}
/*----
出力系
-----*/
// print vector
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = begin(v); it != end(v); ++it) {
    if (it == begin(v))
      os << *it;
    else
      os << " " << *it;
  }
  return os;
}
// print 2d vector
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  for (auto it = begin(v); it != end(v); ++it) {
    os << *it;
    if (it != end(v) - 1) {
      cout << endl;
    }
  }
  return os;
}
// chmin
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
// chmax
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
// bin search
template <class F>
long long bin_search(long long ok, long long ng, const F &f) {
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) >> 1;
    (f(mid) ? ok : ng) = mid;
  }
  return ok;
}
/*------
累積和
------*/
template <typename T> inline vector<T> cumulative_sum(vector<T> &A) {
  vector<T> res;
  int s = 0;
  res.pb(0);
  for (T a : A) {
    s += a;
    res.pb(s);
  }
  return res;
}
template <typename T>
inline vector<vector<T>> cumulative_sum_2d(vector<vector<T>> &A) {
  vector<vector<T>> res;
  int w = SIZE(A[0]) + 1;
  res.pb(vector<T>(w, 0));
  for (vector<T> &a : A) {
    res.pb(cumulative_sum(a));
  }

  rep(i, 1, SIZE(res)) {
    rep(j, w) { res[i][j] += res[i - 1][j]; }
  }
  return res;
}
// vector decrement
template <class T> vector<T> &operator++(vector<T> &v) {
  for (auto &e : v)
    e++;
  return v;
}
template <class T> vector<T> &operator--(vector<T> &v) {
  for (auto &e : v)
    e--;
  return v;
}

/* const value */
const int INF = (1 << 30) + (1LL << 60) - 2;
const int MOD = 998244353;
/* directions */
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};

void solve() { /*This is main.*/
  int N;
  cin >> N;
  int a, b, c;
  cin >> a >> b >> c;
  cout << (N / a + N / b + N / c) - N / lcm(a, b) - N / lcm(b, c) -
              N / lcm(c, a) + (N / lcm(a, lcm(b, c)))
       << endl;
}
signed main(void) {
  std::cin.tie(0)->sync_with_stdio(0);
  cout << fixed << setprecision(15);
  int T = 1;
  // cin>>T;
  rep(T) solve();
  return 0;
}
0