結果

問題 No.316 もっと刺激的なFizzBuzzをください
コンテスト
ユーザー りりんばる
提出日時 2023-10-27 13:11:11
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 385µs
コード長 782 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,205 ms
コンパイル使用メモリ 213,132 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-12 14:11:46
合計ジャッジ時間 3,084 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- )
using namespace std;
using ll = long long;
double pi=3.141592653589793;
const long long inf=2*1e9;
const long long linf=8*1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//atcoder
#include <atcoder/modint>
#include <atcoder/dsu>
using namespace atcoder;
using mint1 = modint1000000007;
using mint2 = modint998244353;

int main() {
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll ans=0;
    ans+=N/A;
    ans+=N/B;
    ans+=N/C;
    ll D=B*C/gcd(B, C);
    ans-=N/D;
    D=B*A/gcd(B, A);
    ans-=N/D;
    D=A*C/gcd(A, C);
    ans-=N/D;
    D=D*B/gcd(B, D);
    ans+=N/D;
    cout << ans;
}
0