結果

問題 No.129 お年玉(2)
ユーザー ducktailducktail
提出日時 2018-09-07 14:12:57
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 425 bytes
コンパイル時間 6,812 ms
コンパイル使用メモリ 163,504 KB
実行使用メモリ 11,448 KB
最終ジャッジ日時 2023-08-18 18:10:34
合計ジャッジ時間 8,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,700 KB
testcase_01 AC 3 ms
7,080 KB
testcase_02 AC 2 ms
6,976 KB
testcase_03 AC 2 ms
7,112 KB
testcase_04 AC 2 ms
7,004 KB
testcase_05 AC 4 ms
8,060 KB
testcase_06 AC 7 ms
11,280 KB
testcase_07 AC 8 ms
11,424 KB
testcase_08 AC 3 ms
7,848 KB
testcase_09 AC 7 ms
11,392 KB
testcase_10 AC 6 ms
11,352 KB
testcase_11 AC 7 ms
11,448 KB
testcase_12 AC 3 ms
7,564 KB
testcase_13 AC 2 ms
7,368 KB
testcase_14 AC 7 ms
11,328 KB
testcase_15 AC 7 ms
11,396 KB
testcase_16 AC 7 ms
11,412 KB
testcase_17 AC 6 ms
10,676 KB
testcase_18 AC 7 ms
11,080 KB
testcase_19 AC 4 ms
8,364 KB
testcase_20 AC 8 ms
11,368 KB
testcase_21 AC 7 ms
11,376 KB
testcase_22 AC 7 ms
10,880 KB
testcase_23 AC 12 ms
11,276 KB
testcase_24 AC 3 ms
7,496 KB
testcase_25 AC 7 ms
11,272 KB
testcase_26 AC 4 ms
9,144 KB
testcase_27 AC 4 ms
9,488 KB
testcase_28 AC 12 ms
11,412 KB
testcase_29 AC 3 ms
6,972 KB
testcase_30 AC 2 ms
6,972 KB
testcase_31 AC 2 ms
6,968 KB
testcase_32 AC 2 ms
7,004 KB
testcase_33 AC 2 ms
6,968 KB
testcase_34 AC 3 ms
7,360 KB
testcase_35 AC 3 ms
7,244 KB
testcase_36 AC 3 ms
7,260 KB
testcase_37 AC 3 ms
7,264 KB
testcase_38 AC 3 ms
8,176 KB
testcase_39 AC 3 ms
8,128 KB
testcase_40 AC 5 ms
9,496 KB
testcase_41 AC 6 ms
9,388 KB
testcase_42 AC 4 ms
8,108 KB
testcase_43 AC 3 ms
7,516 KB
testcase_44 AC 4 ms
8,700 KB
testcase_45 AC 3 ms
7,916 KB
testcase_46 AC 3 ms
7,452 KB
testcase_47 AC 6 ms
10,756 KB
testcase_48 AC 4 ms
7,956 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
import Data.List

main :: IO ()
main = solve <$> readLn <*> readLn >>= print

solve :: Integer -> Integer -> Integer
solve n m = comb m (n `mod` (m * 1000) `div` 1000)

comb :: Integer -> Integer -> Integer
comb n m
  | n < m = 0
  | m == 0 = 1
  | n < 2 * m = comb n (n - m)
  | otherwise = flip mod d $ foldl' f 1 $ zip [n-m+1 .. n] [1 .. m]
  where
    f c (x, y) = c * x `div` y
    d = 10 ^ 9
0