結果

問題 No.492 IOI数列
ユーザー 34056915823405691582
提出日時 2017-03-22 15:07:42
言語 Haskell
(9.6.2)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 540 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 162,512 KB
実行使用メモリ 8,028 KB
最終ジャッジ日時 2023-09-19 05:15:07
合計ジャッジ時間 3,226 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,884 KB
testcase_01 AC 4 ms
7,736 KB
testcase_02 AC 4 ms
7,960 KB
testcase_03 AC 4 ms
7,672 KB
testcase_04 AC 3 ms
7,384 KB
testcase_05 AC 3 ms
7,448 KB
testcase_06 AC 4 ms
8,028 KB
testcase_07 AC 3 ms
7,940 KB
testcase_08 AC 3 ms
7,640 KB
testcase_09 AC 4 ms
7,812 KB
testcase_10 AC 2 ms
7,072 KB
testcase_11 AC 2 ms
7,056 KB
testcase_12 AC 2 ms
7,272 KB
testcase_13 AC 2 ms
7,084 KB
testcase_14 AC 2 ms
7,068 KB
testcase_15 AC 2 ms
7,024 KB
testcase_16 AC 2 ms
7,080 KB
testcase_17 AC 3 ms
7,404 KB
testcase_18 AC 3 ms
7,392 KB
testcase_19 AC 2 ms
7,400 KB
testcase_20 AC 3 ms
7,276 KB
testcase_21 AC 2 ms
7,292 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 #

main = do
  n <- read <$> getLine
  putStrLn $ show $ modIOI n 1000000007
  putStrLn $ show $ modIOI n 101010101010101010101

modIOI an m
  | an == 1 = 1
  | even an = let half = modIOI (div an 2) m in
    mod (half * modExp 10 an m + half) m
  | otherwise = let half = modIOI (div an 2) m in
    mod (half * modExp 10 (2*div an 2) m + half + modExp 10 (2*an-2) m) m

modExp b e m
  | e == 0 = 1
  | even e = let half = modExp b (div e 2) m in
    mod (half*half) m
  | otherwise = let half = modExp b (div e 2) m in
    mod (b*half*half) m
0