結果

問題 No.303 割れません
ユーザー こまるこまる
提出日時 2020-11-21 15:46:38
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 586 bytes
コンパイル時間 8,124 ms
コンパイル使用メモリ 165,944 KB
実行使用メモリ 15,016 KB
最終ジャッジ日時 2023-09-30 21:56:07
合計ジャッジ時間 31,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

main :: IO ()
main = do
  n <- readLn :: IO Integer
  let
    l = if even n
      then let h = l `div` 2 in 2 * fib (h - 1) * fib h
      else fib l
  if l == 0
    then do
      putStrLn "1"
      putStrLn "INF"
    else do
      print n
      print l

fib :: Integer -> Integer
fib i = case fastDoubling i of (a, _) -> a

fastDoubling :: Integer -> (Integer, Integer)
fastDoubling 0 = (0, 1)
fastDoubling 1 = (1, 1)
fastDoubling i =
  let
    (a, b) = fastDoubling (i `div` 2)

  in
    if even i
      then (a * (2 * b - a), a * a + b * b)
      else (a * a + b * b, b * (2 * a + b))
0