結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-17 02:36:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 696 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 41,764 KB
最終ジャッジ日時 2024-05-04 14:38:07
合計ジャッジ時間 8,385 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
40,028 KB
testcase_01 AC 131 ms
41,448 KB
testcase_02 AC 136 ms
41,060 KB
testcase_03 AC 135 ms
41,532 KB
testcase_04 AC 132 ms
41,488 KB
testcase_05 AC 131 ms
41,324 KB
testcase_06 AC 134 ms
41,508 KB
testcase_07 AC 135 ms
41,568 KB
testcase_08 AC 133 ms
41,256 KB
testcase_09 AC 130 ms
41,252 KB
testcase_10 AC 134 ms
41,456 KB
testcase_11 AC 131 ms
41,384 KB
testcase_12 AC 133 ms
41,008 KB
testcase_13 AC 135 ms
41,244 KB
testcase_14 AC 134 ms
41,452 KB
testcase_15 AC 120 ms
40,140 KB
testcase_16 AC 130 ms
40,976 KB
testcase_17 AC 130 ms
41,404 KB
testcase_18 AC 130 ms
41,616 KB
testcase_19 AC 133 ms
41,496 KB
testcase_20 AC 133 ms
40,896 KB
testcase_21 AC 135 ms
41,268 KB
testcase_22 AC 132 ms
41,436 KB
testcase_23 AC 119 ms
40,284 KB
testcase_24 AC 132 ms
41,192 KB
testcase_25 AC 138 ms
41,584 KB
testcase_26 AC 135 ms
41,284 KB
testcase_27 AC 119 ms
40,280 KB
testcase_28 AC 131 ms
41,400 KB
testcase_29 AC 132 ms
41,244 KB
testcase_30 AC 138 ms
41,256 KB
testcase_31 AC 135 ms
41,372 KB
testcase_32 AC 139 ms
41,212 KB
testcase_33 AC 135 ms
41,764 KB
testcase_34 AC 133 ms
41,452 KB
testcase_35 AC 133 ms
41,372 KB
testcase_36 AC 131 ms
41,272 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