結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー legosuke
提出日時 2020-11-24 06:25:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 994 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 192,552 KB
最終ジャッジ日時 2025-01-16 05:21:57
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "test/01_Math/01_NumberTheory/03.01_yukicoder-0316.test.cpp"
#define PROBLEM "https://yukicoder.me/problems/no/316"
#line 1 "template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
#line 3 "01_Math/01_NumberTheory/02.01_gcd.hpp"

/**
 * @brief 最大公約数
 * @docs docs/gcd.md
 */
uint64_t gcd(uint64_t a, uint64_t b) {
    while (b) {
        uint64_t c = a % b;
        a = b;
        b = c;
    }
    return a;
}
#line 3 "01_Math/01_NumberTheory/03.01_lcm.hpp"

/**
 * @brief 最小公倍数
 * @docs docs/lcm.md
 */
uint64_t lcm(uint64_t a, uint64_t b) {
    return a / gcd(a, b) * b;
}
#line 4 "test/01_Math/01_NumberTheory/03.01_yukicoder-0316.test.cpp"

long long num(int n, int x) {
    return n / x;
}

int main() {
    long long N, a, b, c;
    cin >> N >> a >> b >> c;
    long long ans = num(N, a) + num(N, b) + num(N, c);
    ans -= num(N, lcm(a, b)) + num(N, lcm(b, c)) + num(N, lcm(c, a));
    ans += num(N, lcm(a, lcm(b, c)));
    cout << ans << endl;
}
0