結果

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
long long lcm(long long x, long long y)
{
    return (x / __gcd(x, y)) * y;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin >> n;

    long long a, b, c;
    cin >> a >> b >> c;

    int f = 0;

    int a1 = n / a;
    int a2 = n / b;
    int a3 = n / c;

    int q = n / lcm(a, b);
    int w = n / lcm(b, c);
    int t = n / lcm(c, a);
    int r = n / lcm(a, lcm(b, c));
    int cc = a1 + a2 + a3 - q - w - t + r;
    cout << cc << endl;
}
0