結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー spaciaspacia
提出日時 2016-01-14 22:42:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 2,718 ms
コンパイル使用メモリ 77,196 KB
実行使用メモリ 57,676 KB
最終ジャッジ日時 2023-10-19 23:07:42
合計ジャッジ時間 9,187 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,448 KB
testcase_01 AC 129 ms
57,464 KB
testcase_02 WA -
testcase_03 AC 131 ms
57,644 KB
testcase_04 AC 131 ms
57,404 KB
testcase_05 AC 130 ms
57,152 KB
testcase_06 AC 132 ms
57,520 KB
testcase_07 AC 132 ms
57,300 KB
testcase_08 AC 131 ms
57,456 KB
testcase_09 AC 134 ms
57,440 KB
testcase_10 AC 134 ms
57,292 KB
testcase_11 AC 133 ms
57,564 KB
testcase_12 AC 131 ms
57,532 KB
testcase_13 AC 132 ms
57,412 KB
testcase_14 AC 131 ms
57,640 KB
testcase_15 AC 133 ms
57,624 KB
testcase_16 AC 134 ms
57,460 KB
testcase_17 AC 138 ms
57,420 KB
testcase_18 AC 132 ms
57,396 KB
testcase_19 AC 131 ms
57,476 KB
testcase_20 AC 132 ms
57,104 KB
testcase_21 AC 132 ms
57,676 KB
testcase_22 AC 130 ms
57,644 KB
testcase_23 AC 130 ms
57,472 KB
testcase_24 AC 132 ms
57,548 KB
testcase_25 AC 132 ms
57,436 KB
testcase_26 AC 132 ms
57,144 KB
testcase_27 AC 133 ms
57,476 KB
testcase_28 AC 131 ms
57,664 KB
testcase_29 AC 130 ms
57,420 KB
testcase_30 AC 131 ms
57,632 KB
testcase_31 AC 133 ms
57,424 KB
testcase_32 AC 129 ms
57,476 KB
testcase_33 AC 130 ms
57,436 KB
testcase_34 AC 132 ms
57,624 KB
testcase_35 AC 129 ms
55,536 KB
testcase_36 AC 132 ms
57,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static long gcd (long a , long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0) return a;
		return gcd(b , a % b);
	}
	
	public static long solve (int n , int a , int b , int c) {
		long d = a * b / gcd(a , b);
		long e = b * c / gcd(b , c);
		long f = c * a / gcd(c , a);
		long g = c * d / gcd(c , d);
		return n / a + n / b + n / c - (n / d + n / e + n / f) + n / g;
	}
	
	public static void main (String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		out(solve(n,a,b,c));
	}
}
0