結果

問題 No.25 有限小数
ユーザー siman
提出日時 2021-11-17 15:40:28
言語 Ruby
(3.4.1)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 188 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-12-23 15:44:14
合計ジャッジ時間 4,093 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i
M = gets.to_i

cnt = 0
n = N
while n % M != 0 && cnt < 100
  n *= 10
  cnt += 1
end

if n % M == 0
  puts (n / M).to_s.reverse.chars.find { |c| c != '0' }
else
  puts -1
end
0