結果

問題 No.25 有限小数
ユーザー cielciel
提出日時 2014-11-28 18:16:25
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 376 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 19,840 KB
最終ジャッジ日時 2023-09-01 22:45:50
合計ジャッジ時間 16,114 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
15,548 KB
testcase_01 AC 93 ms
15,388 KB
testcase_02 AC 92 ms
15,308 KB
testcase_03 AC 93 ms
15,396 KB
testcase_04 AC 92 ms
15,252 KB
testcase_05 AC 93 ms
15,200 KB
testcase_06 AC 92 ms
15,312 KB
testcase_07 AC 91 ms
15,108 KB
testcase_08 AC 91 ms
15,472 KB
testcase_09 AC 92 ms
15,264 KB
testcase_10 AC 92 ms
15,224 KB
testcase_11 AC 93 ms
15,392 KB
testcase_12 AC 92 ms
15,424 KB
testcase_13 AC 92 ms
15,440 KB
testcase_14 AC 91 ms
15,496 KB
testcase_15 AC 92 ms
15,412 KB
testcase_16 AC 93 ms
15,432 KB
testcase_17 AC 93 ms
15,456 KB
testcase_18 AC 94 ms
15,344 KB
testcase_19 TLE -
testcase_20 AC 97 ms
15,416 KB
testcase_21 AC 98 ms
15,464 KB
testcase_22 AC 92 ms
15,296 KB
testcase_23 AC 91 ms
15,252 KB
testcase_24 AC 91 ms
15,112 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/usr/bin/ruby: 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

ソースコード

diff #

#!/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
0