結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー KAM1KAZEKAM1KAZE
提出日時 2024-01-29 14:19:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 3,873 bytes
コンパイル時間 3,964 ms
コンパイル使用メモリ 254,796 KB
最終ジャッジ日時 2025-02-19 00:39:36
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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