結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー rf141rf141
提出日時 2015-12-19 16:05:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 493 bytes
コンパイル時間 3,070 ms
コンパイル使用メモリ 71,556 KB
実行使用メモリ 56,256 KB
最終ジャッジ日時 2023-08-13 16:10:47
合計ジャッジ時間 8,650 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,752 KB
testcase_01 AC 122 ms
53,960 KB
testcase_02 AC 123 ms
56,256 KB
testcase_03 AC 126 ms
55,904 KB
testcase_04 AC 124 ms
55,340 KB
testcase_05 AC 122 ms
55,380 KB
testcase_06 AC 124 ms
55,756 KB
testcase_07 AC 122 ms
53,904 KB
testcase_08 AC 122 ms
55,896 KB
testcase_09 AC 123 ms
56,000 KB
testcase_10 AC 122 ms
55,864 KB
testcase_11 AC 126 ms
55,632 KB
testcase_12 AC 125 ms
55,856 KB
testcase_13 AC 123 ms
56,012 KB
testcase_14 AC 122 ms
55,664 KB
testcase_15 AC 121 ms
55,436 KB
testcase_16 AC 123 ms
56,180 KB
testcase_17 AC 125 ms
55,680 KB
testcase_18 AC 123 ms
55,880 KB
testcase_19 AC 122 ms
55,744 KB
testcase_20 AC 127 ms
55,744 KB
testcase_21 AC 124 ms
55,720 KB
testcase_22 AC 124 ms
55,432 KB
testcase_23 AC 126 ms
55,824 KB
testcase_24 AC 122 ms
55,608 KB
testcase_25 AC 123 ms
55,676 KB
testcase_26 AC 123 ms
55,720 KB
testcase_27 AC 125 ms
55,736 KB
testcase_28 AC 125 ms
55,940 KB
testcase_29 AC 126 ms
55,740 KB
testcase_30 AC 122 ms
55,860 KB
testcase_31 AC 123 ms
55,800 KB
testcase_32 AC 124 ms
55,920 KB
testcase_33 AC 126 ms
55,740 KB
testcase_34 AC 123 ms
55,716 KB
testcase_35 AC 124 ms
55,388 KB
testcase_36 AC 125 ms
56,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.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)));
	}

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

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