結果

問題 No.25 有限小数
ユーザー char134217728char134217728
提出日時 2017-08-24 23:01:56
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 265 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-23 14:13:48
合計ジャッジ時間 14,306 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,416 KB
testcase_01 AC 88 ms
12,416 KB
testcase_02 AC 87 ms
12,416 KB
testcase_03 WA -
testcase_04 AC 88 ms
12,288 KB
testcase_05 AC 91 ms
12,416 KB
testcase_06 AC 87 ms
12,288 KB
testcase_07 AC 89 ms
12,544 KB
testcase_08 AC 88 ms
12,416 KB
testcase_09 AC 88 ms
12,288 KB
testcase_10 AC 89 ms
12,544 KB
testcase_11 AC 87 ms
12,288 KB
testcase_12 WA -
testcase_13 AC 88 ms
12,288 KB
testcase_14 AC 89 ms
12,288 KB
testcase_15 AC 88 ms
12,416 KB
testcase_16 AC 88 ms
12,288 KB
testcase_17 AC 87 ms
12,416 KB
testcase_18 AC 89 ms
12,544 KB
testcase_19 AC 4,885 ms
12,800 KB
testcase_20 AC 94 ms
12,672 KB
testcase_21 AC 92 ms
12,544 KB
testcase_22 AC 87 ms
12,416 KB
testcase_23 AC 92 ms
12,416 KB
testcase_24 AC 88 ms
12,416 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

require 'prime'
a = gets.to_i
b = gets.to_i
g = a.gcd(b)
a/=g
b/=g
if(a%b==0)
  puts (a/b)%10
  exit
end
pd = Prime.prime_division(b).map(&:first)
pd -= [2,5]
if(pd.empty?)
  r = a.to_r / b
  while r % 1 > 0
    r *= 10
  end
  puts (r % 10).to_i
else
  puts -1
end
0