結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー TatsuDXTatsuDX
提出日時 2016-10-16 21:40:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 639 bytes
コンパイル時間 3,332 ms
コンパイル使用メモリ 74,920 KB
実行使用メモリ 54,428 KB
最終ジャッジ日時 2024-05-02 02:36:54
合計ジャッジ時間 9,627 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,140 KB
testcase_01 AC 133 ms
53,860 KB
testcase_02 AC 132 ms
53,784 KB
testcase_03 AC 132 ms
53,696 KB
testcase_04 AC 132 ms
54,048 KB
testcase_05 AC 133 ms
53,976 KB
testcase_06 AC 134 ms
53,644 KB
testcase_07 AC 133 ms
53,836 KB
testcase_08 AC 131 ms
54,144 KB
testcase_09 AC 134 ms
54,200 KB
testcase_10 AC 139 ms
53,896 KB
testcase_11 AC 137 ms
53,968 KB
testcase_12 AC 138 ms
53,952 KB
testcase_13 AC 134 ms
54,084 KB
testcase_14 AC 131 ms
53,876 KB
testcase_15 AC 133 ms
54,424 KB
testcase_16 AC 136 ms
54,068 KB
testcase_17 AC 131 ms
54,132 KB
testcase_18 AC 133 ms
53,716 KB
testcase_19 AC 134 ms
54,136 KB
testcase_20 AC 135 ms
54,116 KB
testcase_21 AC 133 ms
54,296 KB
testcase_22 AC 135 ms
54,312 KB
testcase_23 AC 134 ms
54,000 KB
testcase_24 AC 135 ms
54,428 KB
testcase_25 AC 139 ms
53,892 KB
testcase_26 AC 133 ms
54,032 KB
testcase_27 AC 135 ms
53,888 KB
testcase_28 AC 134 ms
54,036 KB
testcase_29 AC 135 ms
54,096 KB
testcase_30 AC 134 ms
53,876 KB
testcase_31 AC 133 ms
54,032 KB
testcase_32 AC 134 ms
54,112 KB
testcase_33 AC 132 ms
53,968 KB
testcase_34 AC 133 ms
54,224 KB
testcase_35 AC 133 ms
53,740 KB
testcase_36 AC 135 ms
54,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long n = sc.nextLong(), a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), cnt = 0;
		cnt += n / a;
		cnt += n / b;
		cnt += n / c;
		cnt -= n / (lcm(a, b));
		cnt -= n / (lcm(a, c));
		cnt -= n / (lcm(b, c));
		cnt += n / (lcm(a, lcm(b, c)));
		System.out.println(cnt);
	}

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

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