結果

問題 No.747 循環小数N桁目 Hard
コンテスト
ユーザー Haar
提出日時 2018-11-11 22:29:07
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 517 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,487 ms
コンパイル使用メモリ 195,200 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2026-05-25 18:58:46
合計ジャッジ時間 8,191 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

import Data.Char
import Debug.Trace

main = do
  n <- getLine
  k <- getLine
  let
    r = [2,8,5,7,1,4]
    n' = modBigInteger n 6

    a = case n' of
           0 -> 6
           1 -> 1
           2 -> [4,2] !! (modBigInteger k 2)
           3 -> 3
           4 -> 4
           5 -> [1,5] !! (modBigInteger k 2)

  trace (show a) $ return ()
  
  print $ r !! ((a+5)`mod`6)


modBigInteger :: String -> Int -> Int
modBigInteger [] _ = 0
modBigInteger xs m = foldl (\x y -> (x*10 + y) `mod` m) 0 (map digitToInt xs)
0