結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー spaciaspacia
提出日時 2016-01-14 22:45:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 774 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 78,100 KB
実行使用メモリ 41,564 KB
最終ジャッジ日時 2024-11-21 12:16:14
合計ジャッジ時間 8,830 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,272 KB
testcase_01 AC 137 ms
41,308 KB
testcase_02 AC 138 ms
41,144 KB
testcase_03 AC 134 ms
41,392 KB
testcase_04 AC 137 ms
41,200 KB
testcase_05 AC 139 ms
41,540 KB
testcase_06 AC 136 ms
41,228 KB
testcase_07 AC 135 ms
41,328 KB
testcase_08 AC 138 ms
41,452 KB
testcase_09 AC 134 ms
41,564 KB
testcase_10 AC 135 ms
40,948 KB
testcase_11 AC 137 ms
41,564 KB
testcase_12 AC 138 ms
41,328 KB
testcase_13 AC 138 ms
41,532 KB
testcase_14 AC 139 ms
41,376 KB
testcase_15 AC 138 ms
41,068 KB
testcase_16 AC 139 ms
41,492 KB
testcase_17 AC 139 ms
41,108 KB
testcase_18 AC 137 ms
41,264 KB
testcase_19 AC 136 ms
41,020 KB
testcase_20 AC 138 ms
41,308 KB
testcase_21 AC 139 ms
41,408 KB
testcase_22 AC 136 ms
40,952 KB
testcase_23 AC 135 ms
41,036 KB
testcase_24 AC 136 ms
41,188 KB
testcase_25 AC 139 ms
41,476 KB
testcase_26 AC 136 ms
41,324 KB
testcase_27 AC 137 ms
41,408 KB
testcase_28 AC 136 ms
41,504 KB
testcase_29 AC 136 ms
41,060 KB
testcase_30 AC 134 ms
41,372 KB
testcase_31 AC 131 ms
39,956 KB
testcase_32 AC 140 ms
41,264 KB
testcase_33 AC 137 ms
41,228 KB
testcase_34 AC 139 ms
40,972 KB
testcase_35 AC 134 ms
41,068 KB
testcase_36 AC 137 ms
41,364 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 (long n , long a , long b , long 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);
		
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		
		out(solve(n,a,b,c));
	}
}
0