結果

問題 No.747 循環小数N桁目 Hard
コンテスト
ユーザー manhattaner
提出日時 2018-11-02 13:02:56
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 353 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 409 ms
コンパイル使用メモリ 8,576 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2026-05-14 15:25:22
合計ジャッジ時間 11,437 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

N = gets.to_i
K = gets.to_i

Quotient = "285714"

case n = N % Quotient.size
when 1, 3, 4 then
    puts Quotient[n - 1]
when 2 then
    if K.odd? then
        puts Quotient[1]
    else
        puts Quotient[3]
    end
when 5 then
    if K.odd? then
        puts Quotient[4]
    else
        puts Quotient[0]
    end
when 0 then
    puts Quotient[5]
end
0