結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-17 02:36:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 696 bytes
コンパイル時間 2,851 ms
コンパイル使用メモリ 70,936 KB
実行使用メモリ 56,324 KB
最終ジャッジ日時 2023-08-17 07:47:03
合計ジャッジ時間 8,115 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,180 KB
testcase_01 AC 120 ms
55,988 KB
testcase_02 AC 120 ms
56,324 KB
testcase_03 AC 122 ms
53,892 KB
testcase_04 AC 121 ms
55,800 KB
testcase_05 AC 120 ms
55,728 KB
testcase_06 AC 121 ms
56,200 KB
testcase_07 AC 124 ms
55,524 KB
testcase_08 AC 122 ms
55,720 KB
testcase_09 AC 122 ms
55,484 KB
testcase_10 AC 123 ms
56,244 KB
testcase_11 AC 123 ms
55,844 KB
testcase_12 AC 122 ms
55,676 KB
testcase_13 AC 124 ms
55,672 KB
testcase_14 AC 125 ms
55,828 KB
testcase_15 AC 126 ms
55,544 KB
testcase_16 AC 125 ms
55,984 KB
testcase_17 AC 125 ms
55,580 KB
testcase_18 AC 124 ms
56,012 KB
testcase_19 AC 125 ms
55,732 KB
testcase_20 AC 124 ms
55,884 KB
testcase_21 AC 125 ms
55,768 KB
testcase_22 AC 126 ms
55,708 KB
testcase_23 AC 126 ms
55,836 KB
testcase_24 AC 125 ms
55,748 KB
testcase_25 AC 124 ms
55,908 KB
testcase_26 AC 124 ms
55,448 KB
testcase_27 AC 125 ms
55,756 KB
testcase_28 AC 124 ms
56,096 KB
testcase_29 AC 124 ms
56,184 KB
testcase_30 AC 123 ms
55,840 KB
testcase_31 AC 124 ms
55,728 KB
testcase_32 AC 125 ms
55,944 KB
testcase_33 AC 124 ms
56,156 KB
testcase_34 AC 123 ms
56,180 KB
testcase_35 AC 124 ms
55,656 KB
testcase_36 AC 124 ms
55,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long ablcm = a*b/gcd(a,b);
        long bclcm = b*c/gcd(b,c);
        long calcm = c*a/gcd(c,a);
        long ALLlcm = ablcm*c/gcd(ablcm,c);
        
        long num=N/a+N/b+N/c-N/ablcm-N/bclcm-N/calcm+N/ALLlcm;
        System.out.println(num);
    }
    static long gcd(long x, long y){
        while(true){
            long t=x%y;
            x=y;
            y=t;
            if(t==0){break;}
        }
        return x;
    }
}
0