結果
| 問題 |
No.538 N.G.S.
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2017-06-30 23:12:16 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 505 bytes |
| コンパイル時間 | 9,087 ms |
| コンパイル使用メモリ | 170,624 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 23:55:56 |
| 合計ジャッジ時間 | 6,920 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 51 |
コンパイルメッセージ
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
ソースコード
import Data.Ratio
(%%) :: Integral a => Ratio a -> Ratio a -> Ratio a
n %% d = (numerator n * denominator d) % (denominator n * numerator d)
main :: IO ()
main = do
bs <- map read . words <$> getLine
print $ solve bs
solve :: [Integer] -> Integer
solve [b1, b2, b3] = numerator $ r * toRational b3 + d
where d = (b1 * b3 - b2 ^ 2) % (b1 - b2)
r = if b2 == 0
then -(d - toRational b2) %% toRational b1
else -(d - toRational b3) %% toRational b2
くれちー