結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー legosukelegosuke
提出日時 2020-11-24 06:43:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,022 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 200,048 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-01 00:48:09
合計ジャッジ時間 3,399 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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 count(long long n, long long x) {
    return n / x;
}

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