結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-21 00:08:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 985 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 73,828 KB
実行使用メモリ 41,468 KB
最終ジャッジ日時 2024-04-29 20:03:14
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,204 KB
testcase_01 AC 118 ms
40,048 KB
testcase_02 AC 133 ms
40,852 KB
testcase_03 AC 130 ms
41,280 KB
testcase_04 AC 130 ms
41,004 KB
testcase_05 AC 120 ms
39,712 KB
testcase_06 AC 132 ms
41,160 KB
testcase_07 AC 132 ms
41,252 KB
testcase_08 AC 133 ms
41,128 KB
testcase_09 AC 136 ms
41,432 KB
testcase_10 AC 133 ms
41,256 KB
testcase_11 AC 132 ms
41,120 KB
testcase_12 AC 134 ms
41,340 KB
testcase_13 AC 133 ms
40,972 KB
testcase_14 AC 133 ms
41,408 KB
testcase_15 AC 140 ms
41,188 KB
testcase_16 AC 133 ms
41,336 KB
testcase_17 AC 132 ms
40,976 KB
testcase_18 AC 118 ms
40,112 KB
testcase_19 AC 118 ms
40,004 KB
testcase_20 AC 132 ms
41,128 KB
testcase_21 AC 131 ms
41,124 KB
testcase_22 AC 135 ms
41,468 KB
testcase_23 AC 132 ms
41,176 KB
testcase_24 AC 133 ms
41,244 KB
testcase_25 AC 132 ms
41,460 KB
testcase_26 AC 133 ms
41,152 KB
testcase_27 AC 132 ms
41,216 KB
testcase_28 AC 118 ms
40,192 KB
testcase_29 AC 133 ms
41,392 KB
testcase_30 AC 131 ms
41,284 KB
testcase_31 AC 131 ms
41,372 KB
testcase_32 AC 132 ms
41,364 KB
testcase_33 AC 127 ms
40,968 KB
testcase_34 AC 129 ms
41,136 KB
testcase_35 AC 118 ms
39,828 KB
testcase_36 AC 120 ms
40,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int c=scanner.nextInt();
		long ab=n/lcm(a,b);
		long ac=n/lcm(a,c);
		long bc=n/lcm(b,c);
		long abc=n/lcm(a,lcm(b,c));
		long na=n/a;
		long nb=n/b;
		long nc=n/c;
		System.out.println(na+nb+nc-(ab+ac+bc-abc));
		
	}
	
	/*******************************************************************
	最大公約数
	*******************************************************************/
		static long gcd(long a, long b) {
			long temp;
			while ((temp = a % b) != 0) {
				a = b;
				b = temp;
			}
			return b;
		}

	/*******************************************************************
	最小公倍数
	*******************************************************************/
		static long lcm(long m, long n) {
			return m / gcd(m, n) * n;
		}
}
0