結果

問題 No.1330 Multiply or Divide
ユーザー tamura2004tamura2004
提出日時 2021-01-21 13:12:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 330 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 30,404 KB
最終ジャッジ日時 2023-08-26 00:29:25
合計ジャッジ時間 11,093 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 174 ms
29,464 KB
testcase_02 AC 79 ms
15,084 KB
testcase_03 AC 80 ms
15,352 KB
testcase_04 AC 80 ms
15,092 KB
testcase_05 AC 79 ms
15,120 KB
testcase_06 AC 177 ms
28,484 KB
testcase_07 WA -
testcase_08 AC 188 ms
30,220 KB
testcase_09 AC 198 ms
29,992 KB
testcase_10 AC 189 ms
30,200 KB
testcase_11 AC 186 ms
30,132 KB
testcase_12 AC 188 ms
29,984 KB
testcase_13 AC 79 ms
15,016 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 81 ms
15,016 KB
testcase_17 WA -
testcase_18 AC 180 ms
30,024 KB
testcase_19 AC 179 ms
29,944 KB
testcase_20 AC 182 ms
30,116 KB
testcase_21 AC 182 ms
30,136 KB
testcase_22 AC 179 ms
29,992 KB
testcase_23 AC 183 ms
30,404 KB
testcase_24 AC 80 ms
15,264 KB
testcase_25 AC 78 ms
15,056 KB
testcase_26 AC 83 ms
15,060 KB
testcase_27 AC 80 ms
15,016 KB
testcase_28 AC 81 ms
15,348 KB
testcase_29 AC 81 ms
15,296 KB
testcase_30 AC 80 ms
15,048 KB
testcase_31 AC 80 ms
15,052 KB
testcase_32 AC 80 ms
15,116 KB
testcase_33 AC 81 ms
15,116 KB
testcase_34 AC 154 ms
26,252 KB
testcase_35 AC 100 ms
17,840 KB
testcase_36 AC 151 ms
25,012 KB
testcase_37 AC 142 ms
23,956 KB
testcase_38 AC 117 ms
20,380 KB
testcase_39 AC 106 ms
19,176 KB
testcase_40 AC 112 ms
19,752 KB
testcase_41 AC 96 ms
17,472 KB
testcase_42 AC 138 ms
23,272 KB
testcase_43 AC 148 ms
24,456 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n,m,p = gets.to_s.split.map{ |v| v.to_i }
a = gets.to_s.split.map{ |v| v.to_i }
b = a.map do |v|
  x = v
  while x >= p && x % p == 0
    x /= p
  end
  x
end

am = a.max
bm = b.max

if am < m && bm == 1
  puts -1
  exit
end

ans = 0
x = 1
while x <= m
  ans += 1
  if x * am <= m
    x *= bm
  else
    x *= am
  end
end
puts ans
0