結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,384 KB
testcase_01 AC 122 ms
40,032 KB
testcase_02 AC 138 ms
41,732 KB
testcase_03 AC 139 ms
41,552 KB
testcase_04 AC 137 ms
41,248 KB
testcase_05 AC 133 ms
41,200 KB
testcase_06 AC 133 ms
41,116 KB
testcase_07 AC 130 ms
41,012 KB
testcase_08 AC 134 ms
41,452 KB
testcase_09 AC 133 ms
41,072 KB
testcase_10 AC 134 ms
41,436 KB
testcase_11 AC 133 ms
41,252 KB
testcase_12 AC 137 ms
41,360 KB
testcase_13 AC 137 ms
41,332 KB
testcase_14 AC 137 ms
41,600 KB
testcase_15 AC 121 ms
40,308 KB
testcase_16 AC 139 ms
41,512 KB
testcase_17 AC 125 ms
40,412 KB
testcase_18 AC 146 ms
41,156 KB
testcase_19 AC 136 ms
41,180 KB
testcase_20 AC 138 ms
41,256 KB
testcase_21 AC 141 ms
41,404 KB
testcase_22 AC 134 ms
41,360 KB
testcase_23 AC 145 ms
41,432 KB
testcase_24 AC 144 ms
41,324 KB
testcase_25 AC 142 ms
41,196 KB
testcase_26 AC 142 ms
41,472 KB
testcase_27 AC 136 ms
41,272 KB
testcase_28 AC 121 ms
40,296 KB
testcase_29 AC 134 ms
41,424 KB
testcase_30 AC 148 ms
41,324 KB
testcase_31 AC 141 ms
41,192 KB
testcase_32 AC 141 ms
41,352 KB
testcase_33 AC 144 ms
41,428 KB
testcase_34 AC 138 ms
41,276 KB
testcase_35 AC 138 ms
41,156 KB
testcase_36 AC 138 ms
41,532 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