結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー uafr_csuafr_cs
提出日時 2015-12-09 01:29:57
言語 Java19
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 578 bytes
コンパイル時間 2,728 ms
コンパイル使用メモリ 71,632 KB
実行使用メモリ 58,360 KB
最終ジャッジ日時 2023-08-13 15:37:16
合計ジャッジ時間 8,955 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,196 KB
testcase_01 AC 120 ms
55,804 KB
testcase_02 AC 121 ms
54,216 KB
testcase_03 AC 120 ms
55,772 KB
testcase_04 AC 121 ms
56,048 KB
testcase_05 AC 121 ms
58,360 KB
testcase_06 AC 120 ms
56,336 KB
testcase_07 AC 121 ms
56,040 KB
testcase_08 AC 121 ms
55,752 KB
testcase_09 AC 120 ms
55,868 KB
testcase_10 AC 121 ms
55,652 KB
testcase_11 AC 123 ms
56,008 KB
testcase_12 AC 119 ms
56,520 KB
testcase_13 AC 119 ms
55,612 KB
testcase_14 AC 119 ms
55,340 KB
testcase_15 AC 121 ms
55,612 KB
testcase_16 AC 120 ms
55,972 KB
testcase_17 AC 119 ms
55,624 KB
testcase_18 AC 121 ms
55,764 KB
testcase_19 AC 123 ms
56,108 KB
testcase_20 AC 122 ms
56,324 KB
testcase_21 AC 122 ms
56,040 KB
testcase_22 AC 120 ms
55,380 KB
testcase_23 AC 120 ms
55,912 KB
testcase_24 AC 121 ms
55,952 KB
testcase_25 AC 121 ms
55,776 KB
testcase_26 AC 122 ms
56,380 KB
testcase_27 AC 122 ms
55,796 KB
testcase_28 AC 119 ms
56,296 KB
testcase_29 AC 119 ms
55,744 KB
testcase_30 AC 120 ms
53,924 KB
testcase_31 AC 121 ms
55,760 KB
testcase_32 AC 120 ms
55,876 KB
testcase_33 AC 121 ms
55,844 KB
testcase_34 AC 120 ms
55,404 KB
testcase_35 AC 122 ms
56,296 KB
testcase_36 AC 120 ms
55,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	
	public static long gcd(final long a, final long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static long lcm(final long a, final long b){
		return a / gcd(a, b) * b;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		final long a = sc.nextInt();
		final long b = sc.nextInt();
		final long 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))));
	}

}
0