結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 298 ms
54,632 KB
testcase_02 AC 51 ms
36,456 KB
testcase_03 AC 50 ms
36,604 KB
testcase_04 AC 50 ms
36,608 KB
testcase_05 AC 49 ms
36,940 KB
testcase_06 AC 238 ms
53,444 KB
testcase_07 WA -
testcase_08 AC 310 ms
57,152 KB
testcase_09 AC 323 ms
57,228 KB
testcase_10 AC 322 ms
57,020 KB
testcase_11 AC 305 ms
56,876 KB
testcase_12 AC 320 ms
56,784 KB
testcase_13 AC 51 ms
36,272 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 51 ms
36,868 KB
testcase_17 WA -
testcase_18 AC 308 ms
57,264 KB
testcase_19 AC 299 ms
57,348 KB
testcase_20 AC 305 ms
57,488 KB
testcase_21 AC 308 ms
57,456 KB
testcase_22 AC 311 ms
57,076 KB
testcase_23 AC 316 ms
58,544 KB
testcase_24 AC 51 ms
36,684 KB
testcase_25 AC 50 ms
36,908 KB
testcase_26 AC 52 ms
36,308 KB
testcase_27 AC 50 ms
36,316 KB
testcase_28 AC 50 ms
36,604 KB
testcase_29 AC 50 ms
36,800 KB
testcase_30 AC 51 ms
36,608 KB
testcase_31 AC 51 ms
36,976 KB
testcase_32 AC 51 ms
36,780 KB
testcase_33 AC 52 ms
36,920 KB
testcase_34 AC 321 ms
55,060 KB
testcase_35 AC 170 ms
45,504 KB
testcase_36 AC 262 ms
53,184 KB
testcase_37 AC 267 ms
53,444 KB
testcase_38 AC 224 ms
48,844 KB
testcase_39 AC 174 ms
45,208 KB
testcase_40 AC 204 ms
44,900 KB
testcase_41 AC 150 ms
44,172 KB
testcase_42 AC 247 ms
53,672 KB
testcase_43 AC 269 ms
53,240 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

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();

		for (int i = 0; i < n; i++) {
			if (a[i] > m) {
				System.out.println(1);
				return;
			}
			while (a[i] % p == 0) {
				a[i] /= p;
			}
		}
		int max = 0;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, a[i]);
		}
		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