結果

問題 No.251 大きな桁の復習問題(1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-12-06 22:31:27
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 358 bytes
コンパイル時間 6,380 ms
コンパイル使用メモリ 163,980 KB
実行使用メモリ 30,744 KB
最終ジャッジ日時 2023-10-12 17:33:26
合計ジャッジ時間 8,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,008 KB
testcase_01 AC 2 ms
6,980 KB
testcase_02 AC 3 ms
7,324 KB
testcase_03 AC 3 ms
7,396 KB
testcase_04 AC 3 ms
7,484 KB
testcase_05 AC 3 ms
7,180 KB
testcase_06 AC 2 ms
7,208 KB
testcase_07 AC 3 ms
7,152 KB
testcase_08 AC 3 ms
7,196 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

modexp :: Integral a => a -> a -> a -> a
modexp b ex m
    | ex == 0   = 1
    | even ex   = flip mod m $ square $ flip mod m $ modexp b (div ex 2) m 
    | otherwise = flip mod m $ mod b m * (flip mod m $ modexp b (ex - 1) m)
    where square x = x * x

main :: IO ()
main = print . (\(n : m : _) -> modexp n m 129402307) . map read . lines =<< getContents
0