結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー vjudge1
提出日時 2025-02-18 02:46:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 625 bytes
コンパイル時間 3,360 ms
コンパイル使用メモリ 273,052 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-02-18 02:46:27
合計ジャッジ時間 4,809 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define fastnuces            \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);             \
    int t = 1;

void solve()
{
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    int la = b * c / __gcd(b, c), lb = a * c / __gcd(a, c), lc = a * b / __gcd(a, b);
    int labc = a * la / __gcd(a, la);
    int ans = n / a + n / b + n / c - n / la - n / lb - n / lc + n / labc;
    cout << ans << endl;
}

signed main()
{
    fastnuces;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
0