結果

問題 No.152 貯金箱の消失
ユーザー ducktailducktail
提出日時 2018-09-12 18:19:22
言語 Haskell
(9.6.2)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 2,579 ms
コンパイル使用メモリ 167,456 KB
実行使用メモリ 7,048 KB
最終ジャッジ日時 2023-09-09 14:13:24
合計ジャッジ時間 3,804 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,992 KB
testcase_01 AC 2 ms
7,040 KB
testcase_02 AC 3 ms
6,864 KB
testcase_03 AC 2 ms
7,016 KB
testcase_04 AC 3 ms
7,040 KB
testcase_05 AC 3 ms
7,036 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 4 ms
6,952 KB
testcase_08 AC 11 ms
6,952 KB
testcase_09 AC 11 ms
6,952 KB
testcase_10 AC 8 ms
6,936 KB
testcase_11 AC 5 ms
7,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

import Control.Applicative

main :: IO ()
main = solve <$> flip div 4 <$> readLn >>= print

solve :: Int -> Int
solve l = f 0 1 2
  where
    f c n m
      | 2 * (n + 1) * (2 * n + 1) > l = c `mod` 1000003
      | 2 * m * (m + n) > l = f c (n + 1) (n + 2)
      | odd (m - n) && gcd n m == 1 = f (c + 1) n (m + 1)
      | otherwise = f c n (m + 1)
0