結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー htensaihtensai
提出日時 2019-11-21 20:22:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 2,473 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 41,792 KB
最終ジャッジ日時 2024-04-19 07:34:41
合計ジャッジ時間 7,655 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
40,508 KB
testcase_01 AC 124 ms
41,336 KB
testcase_02 AC 126 ms
41,424 KB
testcase_03 AC 130 ms
41,792 KB
testcase_04 AC 118 ms
40,900 KB
testcase_05 AC 125 ms
41,364 KB
testcase_06 AC 127 ms
41,464 KB
testcase_07 AC 127 ms
41,280 KB
testcase_08 AC 115 ms
40,216 KB
testcase_09 AC 123 ms
41,012 KB
testcase_10 AC 114 ms
40,216 KB
testcase_11 AC 123 ms
41,524 KB
testcase_12 AC 111 ms
40,544 KB
testcase_13 AC 113 ms
40,032 KB
testcase_14 AC 126 ms
41,704 KB
testcase_15 AC 132 ms
41,556 KB
testcase_16 AC 113 ms
40,332 KB
testcase_17 AC 118 ms
40,244 KB
testcase_18 AC 115 ms
40,252 KB
testcase_19 AC 126 ms
41,516 KB
testcase_20 AC 129 ms
41,492 KB
testcase_21 AC 127 ms
41,276 KB
testcase_22 AC 132 ms
41,396 KB
testcase_23 AC 128 ms
41,196 KB
testcase_24 AC 113 ms
40,008 KB
testcase_25 AC 126 ms
41,364 KB
testcase_26 AC 117 ms
40,768 KB
testcase_27 AC 125 ms
41,528 KB
testcase_28 AC 117 ms
40,624 KB
testcase_29 AC 121 ms
40,740 KB
testcase_30 AC 123 ms
41,580 KB
testcase_31 AC 117 ms
40,472 KB
testcase_32 AC 126 ms
41,328 KB
testcase_33 AC 125 ms
41,148 KB
testcase_34 AC 113 ms
40,032 KB
testcase_35 AC 124 ms
41,240 KB
testcase_36 AC 128 ms
41,288 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 ans = n / a + n / b + n / c - n / lcm(a, b) - n / lcm(b, c) - n / lcm(c, a) + n / lcm(lcm(a, b), c);
		System.out.println(ans);
	}
	
	static long lcm(long x, long y) {
	    return x / gcd(x, y) * y;
	}
	
	static long gcd(long x, long y) {
	    if (x % y == 0) {
	        return y;
	    } else {
	        return gcd(y, x % y);
	    }
	}
}
0