結果

問題 No.538 N.G.S.
ユーザー くれちー
提出日時 2017-06-30 23:06:57
言語 Haskell
(9.10.1)
結果
RE  
実行時間 -
コード長 410 bytes
コンパイル時間 6,439 ms
コンパイル使用メモリ 172,800 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 21:11:07
合計ジャッジ時間 7,625 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 50 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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 = -(d - toRational b2) %% toRational b1
0