結果

問題 No.25 有限小数
ユーザー finefine
提出日時 2017-01-09 18:44:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 457 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-08-22 21:53:16
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,072 KB
testcase_01 AC 83 ms
15,236 KB
testcase_02 AC 82 ms
15,124 KB
testcase_03 AC 82 ms
15,276 KB
testcase_04 AC 82 ms
15,324 KB
testcase_05 AC 86 ms
15,084 KB
testcase_06 AC 84 ms
15,092 KB
testcase_07 AC 81 ms
15,020 KB
testcase_08 AC 82 ms
15,256 KB
testcase_09 AC 81 ms
15,328 KB
testcase_10 AC 82 ms
15,080 KB
testcase_11 AC 82 ms
15,232 KB
testcase_12 AC 85 ms
15,332 KB
testcase_13 AC 82 ms
15,320 KB
testcase_14 AC 81 ms
15,164 KB
testcase_15 AC 81 ms
15,084 KB
testcase_16 AC 81 ms
15,276 KB
testcase_17 AC 82 ms
15,344 KB
testcase_18 AC 82 ms
15,064 KB
testcase_19 AC 81 ms
15,260 KB
testcase_20 AC 80 ms
15,168 KB
testcase_21 AC 81 ms
15,344 KB
testcase_22 AC 81 ms
15,068 KB
testcase_23 AC 81 ms
15,096 KB
testcase_24 AC 82 ms
15,124 KB
testcase_25 AC 81 ms
15,104 KB
testcase_26 AC 82 ms
15,168 KB
testcase_27 AC 82 ms
15,104 KB
testcase_28 AC 83 ms
15,272 KB
testcase_29 AC 83 ms
15,248 KB
testcase_30 AC 83 ms
15,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:16: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n, m = $<.map(&:to_i)
g = n.gcd(m)
n /= g
m /= g
if m != 1
    cnt = [0,0]
    while m % 2 == 0
        cnt[0] += 1
        m /= 2
    end
    while m % 5 == 0
        cnt[1] += 1
        m /= 5
    end
    if m != 1
        p -1
        exit
    end
    if cnt[0] > cnt[1]
        n *= 5 ** (cnt[0] - cnt[1])
    else 
        n *= 2 ** (cnt[1] - cnt[0])
    end
end
s = n.to_s.reverse
s.size.times do |i|
    next if s[i] == ?0
    puts s[i]
    break
end
0