結果

問題 No.1330 Multiply or Divide
ユーザー ks2mks2m
提出日時 2021-01-08 21:33:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 77,740 KB
実行使用メモリ 68,704 KB
最終ジャッジ日時 2024-04-28 02:13:54
合計ジャッジ時間 11,449 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 297 ms
64,404 KB
testcase_02 WA -
testcase_03 AC 43 ms
49,960 KB
testcase_04 AC 44 ms
50,536 KB
testcase_05 AC 44 ms
50,196 KB
testcase_06 AC 200 ms
63,912 KB
testcase_07 WA -
testcase_08 AC 397 ms
68,216 KB
testcase_09 AC 389 ms
68,704 KB
testcase_10 AC 395 ms
68,584 KB
testcase_11 AC 389 ms
68,288 KB
testcase_12 AC 317 ms
68,468 KB
testcase_13 AC 47 ms
49,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 47 ms
50,076 KB
testcase_17 WA -
testcase_18 AC 314 ms
68,508 KB
testcase_19 AC 388 ms
68,564 KB
testcase_20 AC 326 ms
68,616 KB
testcase_21 AC 395 ms
68,228 KB
testcase_22 AC 373 ms
68,464 KB
testcase_23 AC 270 ms
67,948 KB
testcase_24 AC 45 ms
50,388 KB
testcase_25 AC 43 ms
50,216 KB
testcase_26 AC 43 ms
50,088 KB
testcase_27 AC 44 ms
50,088 KB
testcase_28 AC 47 ms
49,960 KB
testcase_29 AC 44 ms
50,184 KB
testcase_30 AC 45 ms
50,352 KB
testcase_31 AC 46 ms
50,072 KB
testcase_32 AC 45 ms
49,912 KB
testcase_33 AC 44 ms
50,080 KB
testcase_34 AC 298 ms
64,608 KB
testcase_35 AC 164 ms
58,108 KB
testcase_36 AC 323 ms
63,436 KB
testcase_37 AC 270 ms
63,712 KB
testcase_38 AC 215 ms
60,364 KB
testcase_39 AC 186 ms
58,112 KB
testcase_40 AC 196 ms
55,924 KB
testcase_41 AC 146 ms
55,676 KB
testcase_42 AC 263 ms
63,420 KB
testcase_43 AC 260 ms
63,168 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 <= 1) {
			System.out.println(-1);
		} else {
			long x = 1;
			int ans = 0;
			while (x <= m) {
				ans++;
				x *= max;
			}
			System.out.println(ans);
		}
	}
}
0