結果
問題 | No.403 2^2^2 |
ユーザー |
![]() |
提出日時 | 2020-07-26 22:58:49 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 3,515 ms |
コンパイル使用メモリ | 180,396 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 19:34:06 |
合計ジャッジ時間 | 4,318 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
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
ソースコード
{-# LANGUAGE CPP #-} import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Maybe as Maybe #define MOD 1000000007 {-# INLINE modulus #-} modulus :: (Num a) => a modulus = MOD rui :: Integer -> Integer -> Integer -> Integer rui 1 _ _ = 1 rui _ 0 _ = 1 rui a x p | even x = z * z `mod` p | otherwise = a * z * z `mod` p where z = rui a (x `div` 2) p main :: IO () main = do xs <- BSC8.split '^' <$> BSC8.getLine let (a:b:c:_) = map (fst . Maybe.fromJust . BSC8.readInteger) xs let _a = a `mod`modulus putStr $ show $ rui (rui _a b modulus) c modulus putStr " " if _a == 0 then print 0 else print $ rui _a (rui b c (modulus - 1)) modulus