結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー sue_charosue_charo
提出日時 2017-04-28 12:34:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 691 bytes
コンパイル時間 4,470 ms
コンパイル使用メモリ 79,456 KB
実行使用メモリ 56,596 KB
最終ジャッジ日時 2023-10-11 18:51:53
合計ジャッジ時間 10,450 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,972 KB
testcase_01 AC 123 ms
56,028 KB
testcase_02 AC 123 ms
56,028 KB
testcase_03 AC 121 ms
56,496 KB
testcase_04 AC 121 ms
56,068 KB
testcase_05 AC 122 ms
56,204 KB
testcase_06 AC 122 ms
56,596 KB
testcase_07 AC 119 ms
56,040 KB
testcase_08 AC 122 ms
55,468 KB
testcase_09 AC 126 ms
55,820 KB
testcase_10 AC 124 ms
55,696 KB
testcase_11 AC 121 ms
55,768 KB
testcase_12 AC 121 ms
55,924 KB
testcase_13 AC 123 ms
54,052 KB
testcase_14 AC 120 ms
55,844 KB
testcase_15 AC 123 ms
55,752 KB
testcase_16 AC 121 ms
55,792 KB
testcase_17 AC 123 ms
53,764 KB
testcase_18 AC 120 ms
55,752 KB
testcase_19 AC 121 ms
55,812 KB
testcase_20 AC 120 ms
56,144 KB
testcase_21 AC 120 ms
55,772 KB
testcase_22 AC 123 ms
56,064 KB
testcase_23 AC 125 ms
55,496 KB
testcase_24 AC 124 ms
56,116 KB
testcase_25 AC 125 ms
55,744 KB
testcase_26 AC 121 ms
55,692 KB
testcase_27 AC 120 ms
55,740 KB
testcase_28 AC 120 ms
55,740 KB
testcase_29 AC 121 ms
55,944 KB
testcase_30 AC 120 ms
55,744 KB
testcase_31 AC 121 ms
56,580 KB
testcase_32 AC 121 ms
56,256 KB
testcase_33 AC 120 ms
55,816 KB
testcase_34 AC 122 ms
55,952 KB
testcase_35 AC 122 ms
56,264 KB
testcase_36 AC 125 ms
56,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yuki316 {
    public static void main(String[] args) {
        long N;
        int a;
        int b;
        int c;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextLong();
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
        }

        System.out.println(N / a + N / b + N / c - N / lcm(a, b) - N / lcm(b, c) - N / lcm(c, a) + N / lcm(a, lcm(b, c)));
    }

    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, (a % b));
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }
}
0