結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー rabimea
提出日時 2025-09-28 07:10:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 607 bytes
コンパイル時間 3,175 ms
コンパイル使用メモリ 276,148 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-28 07:10:25
合計ジャッジ時間 4,573 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    ll n; ll a[3];
    cin >> n >> a[0] >> a[1] >> a[2] >> a[3];
    ll ans = 0;
    for(int k = 1; k < 1 << 3; k ++) {
        ll lcm = 1;
        for(int i = 0; i < 3; i ++) if((k >> i) & 1)
            lcm = std::lcm(lcm, a[i]);
        int sgn = __builtin_popcount(k) % 2 == 1 ? 1 : -1;
        ans += sgn * (n / lcm);
    }
    cout << ans << '\n';
}
0