結果
問題 | No.1330 Multiply or Divide |
ユーザー |
![]() |
提出日時 | 2021-01-08 21:49:10 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 900 bytes |
コンパイル時間 | 5,728 ms |
コンパイル使用メモリ | 77,056 KB |
実行使用メモリ | 64,516 KB |
最終ジャッジ日時 | 2024-11-16 12:04:07 |
合計ジャッジ時間 | 13,617 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 7 RE * 24 |
ソースコード
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) { throw new Exception(); } 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); } } }