結果
問題 | No.344 ある無理数の累乗 |
ユーザー |
|
提出日時 | 2020-11-07 09:32:47 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 610 bytes |
コンパイル時間 | 10,648 ms |
コンパイル使用メモリ | 172,928 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 14:21:26 |
合計ジャッジ時間 | 10,820 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
modulo::Intmodulo = 1000INLINEtype Number = (Int, Int)infixr 8 @^@infixl 7 @*@(@*@) :: Number -> Number -> Number(ap, aq) @*@ (bp, bq) = ((ap * bp + 3 * aq * bq) `mod` modulo, (ap * bq + aq * bp) `mod` modulo)INLINE(@^@) :: Number -> Int -> Numbera @^@ i| i == 0 = (1, 0)| odd i = res @*@ a| otherwise = reswhereres::Numberres = (a @*@ a) @^@ (div i 2)INLINEmain::IO()main = don <- readLn :: IO Intlet x = (1, 1) @^@ nprint $ if even n then ((fst x) * 2 - 1) `mod` modulo else ((fst x) * 2) `mod` modulo