結果
問題 | No.1330 Multiply or Divide |
ユーザー | tenten |
提出日時 | 2023-02-02 09:47:28 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,384 bytes |
コンパイル時間 | 2,919 ms |
コンパイル使用メモリ | 90,376 KB |
実行使用メモリ | 52,656 KB |
最終ジャッジ日時 | 2024-07-02 00:17:03 |
合計ジャッジ時間 | 14,167 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 274 ms
47,252 KB |
testcase_02 | AC | 53 ms
36,776 KB |
testcase_03 | AC | 54 ms
37,064 KB |
testcase_04 | AC | 53 ms
36,716 KB |
testcase_05 | AC | 53 ms
36,648 KB |
testcase_06 | AC | 214 ms
45,340 KB |
testcase_07 | WA | - |
testcase_08 | AC | 366 ms
51,604 KB |
testcase_09 | AC | 364 ms
51,560 KB |
testcase_10 | AC | 363 ms
50,588 KB |
testcase_11 | AC | 363 ms
51,632 KB |
testcase_12 | AC | 363 ms
50,952 KB |
testcase_13 | AC | 55 ms
36,964 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 53 ms
36,736 KB |
testcase_17 | WA | - |
testcase_18 | AC | 369 ms
51,836 KB |
testcase_19 | AC | 367 ms
51,648 KB |
testcase_20 | AC | 359 ms
51,764 KB |
testcase_21 | AC | 352 ms
51,608 KB |
testcase_22 | AC | 361 ms
50,116 KB |
testcase_23 | AC | 291 ms
52,656 KB |
testcase_24 | AC | 54 ms
36,776 KB |
testcase_25 | AC | 53 ms
36,944 KB |
testcase_26 | AC | 55 ms
36,976 KB |
testcase_27 | AC | 53 ms
36,684 KB |
testcase_28 | AC | 53 ms
36,644 KB |
testcase_29 | AC | 54 ms
36,488 KB |
testcase_30 | AC | 55 ms
36,944 KB |
testcase_31 | AC | 55 ms
36,716 KB |
testcase_32 | AC | 54 ms
36,812 KB |
testcase_33 | AC | 53 ms
36,952 KB |
testcase_34 | AC | 310 ms
47,052 KB |
testcase_35 | AC | 210 ms
44,324 KB |
testcase_36 | AC | 299 ms
47,144 KB |
testcase_37 | AC | 289 ms
46,952 KB |
testcase_38 | AC | 226 ms
44,780 KB |
testcase_39 | AC | 225 ms
44,840 KB |
testcase_40 | AC | 222 ms
44,704 KB |
testcase_41 | AC | 177 ms
42,472 KB |
testcase_42 | AC | 297 ms
47,376 KB |
testcase_43 | AC | 300 ms
47,256 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int p = sc.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } Arrays.sort(values); if (values[n - 1] > m) { System.out.println(1); return; } int realMax = values[n - 1]; int currentMax = 0; for (int i = n - 1; i >= 0; i--) { if (values[i] % p > 0) { currentMax = values[i]; break; } } if (currentMax == 0) { System.out.println(-1); return; } int ans = 0; long base = 1; while (base <= m) { if (base * realMax > m) { base *= realMax; ans++; } else { base *= currentMax; ans++; } } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }