結果

問題 No.1330 Multiply or Divide
ユーザー ks2mks2m
提出日時 2021-01-08 21:29:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 77,780 KB
実行使用メモリ 58,240 KB
最終ジャッジ日時 2024-04-28 02:05:13
合計ジャッジ時間 14,277 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 328 ms
54,784 KB
testcase_02 WA -
testcase_03 AC 51 ms
36,736 KB
testcase_04 AC 51 ms
36,708 KB
testcase_05 AC 51 ms
37,196 KB
testcase_06 AC 235 ms
53,576 KB
testcase_07 WA -
testcase_08 AC 408 ms
57,664 KB
testcase_09 AC 470 ms
57,604 KB
testcase_10 AC 473 ms
58,240 KB
testcase_11 AC 472 ms
57,240 KB
testcase_12 AC 383 ms
57,704 KB
testcase_13 AC 52 ms
36,444 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 51 ms
36,376 KB
testcase_17 WA -
testcase_18 AC 403 ms
57,580 KB
testcase_19 AC 392 ms
57,232 KB
testcase_20 AC 472 ms
57,620 KB
testcase_21 AC 422 ms
57,836 KB
testcase_22 AC 393 ms
57,532 KB
testcase_23 AC 322 ms
58,156 KB
testcase_24 AC 51 ms
37,084 KB
testcase_25 AC 51 ms
37,056 KB
testcase_26 AC 51 ms
36,688 KB
testcase_27 AC 52 ms
36,736 KB
testcase_28 AC 51 ms
36,396 KB
testcase_29 AC 53 ms
36,948 KB
testcase_30 AC 53 ms
36,856 KB
testcase_31 AC 52 ms
36,844 KB
testcase_32 AC 51 ms
37,056 KB
testcase_33 AC 51 ms
36,444 KB
testcase_34 AC 396 ms
54,764 KB
testcase_35 AC 196 ms
46,268 KB
testcase_36 AC 380 ms
54,008 KB
testcase_37 AC 313 ms
53,860 KB
testcase_38 AC 258 ms
49,544 KB
testcase_39 AC 219 ms
46,508 KB
testcase_40 AC 238 ms
45,040 KB
testcase_41 AC 176 ms
45,504 KB
testcase_42 AC 305 ms
53,872 KB
testcase_43 AC 324 ms
54,064 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int p = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Arrays.sort(a);
		int max = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (a[i] % p != 0) {
				max = a[i];
				break;
			}
		}
		if (max == 0) {
			System.out.println(-1);
		} else {
			long x = 1;
			int ans = 0;
			while (x <= m) {
				ans++;
				x *= max;
			}
			System.out.println(ans);
		}
	}
}
0