結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-28 18:16:25 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 376 bytes |
| コンパイル時間 | 978 ms |
| コンパイル使用メモリ | 7,808 KB |
| 実行使用メモリ | 25,728 KB |
| 最終ジャッジ日時 | 2025-01-03 10:21:02 |
| 合計ジャッジ時間 | 21,288 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 TLE * 2 |
コンパイルメッセージ
Main.rb:1: warning: shebang line ending with \r may cause problems Main.rb:13: warning: ambiguous first argument; put parentheses or a space even after `-` operator Syntax OK
ソースコード
#!/usr/bin/ruby
require 'rational'
require 'prime'
n=gets.to_i
m=gets.to_i
g=n.gcd(m)
n/=g
m/=g
n/=10 while n%10==0
m/=10 while m%10==0
div=m.prime_division
if div.any?{|n,p|n!=2&&n!=5}
p -1
exit
end
div=Hash[*div.flatten(1)]
n%=10
(div[2]||0).times{|i|
n*=5
n = n%10==0 ? n/10 : n%10
}
(div[5]||0).times{|i|
n*=2
n = n%10==0 ? n/10 : n%10
}
p n