結果
問題 | No.1330 Multiply or Divide |
ユーザー | 箱星 |
提出日時 | 2021-01-08 21:35:27 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,265 bytes |
コンパイル時間 | 15,068 ms |
コンパイル使用メモリ | 446,348 KB |
実行使用メモリ | 95,684 KB |
最終ジャッジ日時 | 2024-11-16 10:30:11 |
合計ジャッジ時間 | 37,799 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 547 ms
90,888 KB |
testcase_02 | AC | 319 ms
59,936 KB |
testcase_03 | AC | 320 ms
59,860 KB |
testcase_04 | AC | 318 ms
59,788 KB |
testcase_05 | AC | 313 ms
59,912 KB |
testcase_06 | AC | 545 ms
78,640 KB |
testcase_07 | AC | 685 ms
95,684 KB |
testcase_08 | AC | 591 ms
93,972 KB |
testcase_09 | AC | 584 ms
93,708 KB |
testcase_10 | AC | 602 ms
93,912 KB |
testcase_11 | AC | 579 ms
91,228 KB |
testcase_12 | AC | 587 ms
93,860 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 573 ms
90,764 KB |
testcase_19 | AC | 587 ms
90,768 KB |
testcase_20 | AC | 572 ms
90,676 KB |
testcase_21 | AC | 577 ms
90,928 KB |
testcase_22 | AC | 568 ms
90,740 KB |
testcase_23 | AC | 589 ms
89,912 KB |
testcase_24 | AC | 313 ms
54,116 KB |
testcase_25 | AC | 322 ms
54,032 KB |
testcase_26 | AC | 316 ms
54,064 KB |
testcase_27 | AC | 317 ms
54,120 KB |
testcase_28 | AC | 321 ms
54,176 KB |
testcase_29 | AC | 316 ms
54,184 KB |
testcase_30 | AC | 322 ms
54,176 KB |
testcase_31 | AC | 318 ms
54,052 KB |
testcase_32 | AC | 323 ms
53,924 KB |
testcase_33 | AC | 321 ms
54,156 KB |
testcase_34 | AC | 574 ms
76,248 KB |
testcase_35 | AC | 475 ms
60,844 KB |
testcase_36 | AC | 563 ms
74,232 KB |
testcase_37 | AC | 537 ms
72,696 KB |
testcase_38 | AC | 519 ms
65,828 KB |
testcase_39 | AC | 490 ms
62,272 KB |
testcase_40 | AC | 495 ms
64,960 KB |
testcase_41 | AC | 471 ms
60,080 KB |
testcase_42 | AC | 518 ms
71,668 KB |
testcase_43 | AC | 553 ms
73,472 KB |
testcase_44 | AC | 563 ms
74,884 KB |
testcase_45 | AC | 567 ms
75,008 KB |
コンパイルメッセージ
Main.kt:18:24: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long val max_a = a.max()!! ^ Main.kt:19:24: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long val max_b = b.max()!! ^ Main.kt:20:72: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int val cnt = (0 until n).filter { b[it] == max_b }.map { c[it] }.min()!! ^
ソースコード
import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val m = nextLong() val p = nextLong() val a = Array(n) { nextLong() } val b = a.copyOf() val c = Array(n) { 0 } for (i in 0 until n) { while (b[i] % p == 0L) { b[i] /= p c[i]++ } } val max_a = a.max()!! val max_b = b.max()!! val cnt = (0 until n).filter { b[it] == max_b }.map { c[it] }.min()!! if (max_b == 1L && max_a < m) { println(-1) return } var now = 1L var ans = 0 while (now <= m) { if (now * max_a > m) { ans++ break } else { now *= max_b ans += cnt + 1 } } println(ans) } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine()!! fun nextDouble() = next().toDouble() // endregion