結果
| 問題 |
No.403 2^2^2
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-07-23 20:41:49 |
| 言語 | Haskell (9.10.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 628 bytes |
| コンパイル時間 | 9,374 ms |
| コンパイル使用メモリ | 173,568 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 15:26:25 |
| 合計ジャッジ時間 | 10,194 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
コンパイルメッセージ
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 BangPatterns #-}
import Control.Applicative ((<$>))
import Data.Int (Int64)
import Data.List.Split (splitOn)
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 * mod (modexp b (ex - 1) m) m
where square x = x * x
p :: Integral a => a
p = 10 ^ 9 + 7
main :: IO ()
main = do
![a, b, c] <- fmap read . splitOn "^" <$> getLine :: IO [Int64]
let !x = modexp (modexp a b p) c p
let !y = modexp a (modexp b c $ p - 1) p
putStrLn . unwords . fmap show $ [x, y]
はむ吉🐹