結果

問題 No.1330 Multiply or Divide
ユーザー ks2mks2m
提出日時 2021-01-08 22:17:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 77,728 KB
実行使用メモリ 71,812 KB
最終ジャッジ日時 2024-04-28 03:33:00
合計ジャッジ時間 12,632 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 319 ms
70,200 KB
testcase_02 AC 54 ms
50,340 KB
testcase_03 AC 55 ms
50,528 KB
testcase_04 RE -
testcase_05 AC 55 ms
50,236 KB
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 329 ms
70,988 KB
testcase_09 AC 346 ms
71,004 KB
testcase_10 AC 340 ms
71,192 KB
testcase_11 AC 335 ms
71,088 KB
testcase_12 AC 351 ms
71,248 KB
testcase_13 AC 59 ms
50,212 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 55 ms
50,384 KB
testcase_17 WA -
testcase_18 AC 312 ms
70,776 KB
testcase_19 AC 327 ms
70,928 KB
testcase_20 AC 317 ms
70,836 KB
testcase_21 AC 320 ms
71,412 KB
testcase_22 AC 316 ms
70,892 KB
testcase_23 AC 350 ms
71,812 KB
testcase_24 AC 56 ms
50,296 KB
testcase_25 AC 57 ms
50,428 KB
testcase_26 AC 56 ms
50,280 KB
testcase_27 AC 54 ms
50,100 KB
testcase_28 AC 54 ms
50,240 KB
testcase_29 AC 57 ms
50,292 KB
testcase_30 AC 55 ms
50,036 KB
testcase_31 AC 54 ms
50,384 KB
testcase_32 AC 56 ms
50,404 KB
testcase_33 AC 57 ms
50,236 KB
testcase_34 AC 322 ms
64,780 KB
testcase_35 AC 174 ms
56,944 KB
testcase_36 AC 279 ms
64,088 KB
testcase_37 AC 263 ms
63,552 KB
testcase_38 AC 197 ms
60,308 KB
testcase_39 AC 184 ms
57,852 KB
testcase_40 AC 207 ms
55,844 KB
testcase_41 AC 154 ms
54,940 KB
testcase_42 AC 248 ms
63,620 KB
testcase_43 AC 269 ms
63,880 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();

		int[] b = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			if (a[i] > m) {
				System.out.println(1);
				return;
			}
			b[i] = a[i];
			while (b[i] % p == 0) {
				b[i] /= p;
			}
			c[i] = m / a[i] + 1;
		}

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			if (b[i] == 1) {
				continue;
			}
			long x = 1;
			int cnt = 0;
			while (x < c[i]) {
				cnt++;
				x *= b[i];
			}
			ans = Math.min(ans, cnt + 1);
		}
		if (ans == Integer.MAX_VALUE) {
			throw new Exception();
		}
		System.out.println(ans);
	}
}
0