結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー samplelpmassamplelpmas
提出日時 2017-05-03 20:00:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 2,503 ms
コンパイル使用メモリ 71,860 KB
実行使用メモリ 58,560 KB
最終ジャッジ日時 2023-10-12 08:01:26
合計ジャッジ時間 8,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,780 KB
testcase_01 AC 118 ms
55,760 KB
testcase_02 WA -
testcase_03 AC 119 ms
55,808 KB
testcase_04 AC 120 ms
55,872 KB
testcase_05 AC 119 ms
55,788 KB
testcase_06 AC 122 ms
55,672 KB
testcase_07 AC 120 ms
55,676 KB
testcase_08 AC 119 ms
55,988 KB
testcase_09 AC 122 ms
55,724 KB
testcase_10 AC 121 ms
55,988 KB
testcase_11 AC 120 ms
58,560 KB
testcase_12 AC 119 ms
56,044 KB
testcase_13 AC 120 ms
55,576 KB
testcase_14 AC 120 ms
56,152 KB
testcase_15 AC 119 ms
55,812 KB
testcase_16 AC 120 ms
55,572 KB
testcase_17 AC 119 ms
55,520 KB
testcase_18 AC 119 ms
55,784 KB
testcase_19 AC 119 ms
55,868 KB
testcase_20 AC 120 ms
55,780 KB
testcase_21 AC 119 ms
56,716 KB
testcase_22 AC 120 ms
55,828 KB
testcase_23 AC 123 ms
56,088 KB
testcase_24 AC 122 ms
54,244 KB
testcase_25 AC 120 ms
55,760 KB
testcase_26 AC 121 ms
55,528 KB
testcase_27 AC 122 ms
55,996 KB
testcase_28 AC 120 ms
55,752 KB
testcase_29 AC 119 ms
55,816 KB
testcase_30 AC 120 ms
56,048 KB
testcase_31 AC 118 ms
55,768 KB
testcase_32 AC 119 ms
55,772 KB
testcase_33 AC 120 ms
55,532 KB
testcase_34 AC 121 ms
56,412 KB
testcase_35 AC 118 ms
56,064 KB
testcase_36 AC 118 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        long lcmAB = lcm(a, b);
        long lcmBC = lcm(b, c);
        long lcmCA = lcm(c, a);

        long lcmABC = lcm(lcmAB, c);

        long answer = (N / a) + (N / b) + (N / c) + (N / lcmABC) - (N / lcmAB) - (N / lcmBC) - (N / lcmCA);

        System.out.println(answer);

    }

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

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

}
0