結果

問題 No.751 Frac #2
ユーザー ducktailducktail
提出日時 2018-11-09 22:11:03
言語 Haskell
(9.2.2)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 526 bytes
コンパイル時間 805 ms
使用メモリ 4,432 KB
最終ジャッジ日時 2022-12-26 20:06:30
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,120 KB
testcase_01 AC 2 ms
4,340 KB
testcase_02 AC 2 ms
4,432 KB
testcase_03 AC 2 ms
4,224 KB
testcase_04 AC 2 ms
4,256 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,216 KB
testcase_07 AC 2 ms
4,328 KB
testcase_08 AC 2 ms
4,300 KB
testcase_09 AC 2 ms
4,124 KB
testcase_10 AC 2 ms
4,128 KB
testcase_11 AC 2 ms
4,328 KB
testcase_12 AC 2 ms
4,040 KB
testcase_13 AC 2 ms
4,280 KB
testcase_14 AC 2 ms
4,276 KB
testcase_15 AC 2 ms
4,284 KB
testcase_16 AC 2 ms
4,264 KB
testcase_17 AC 2 ms
4,276 KB
testcase_18 AC 2 ms
4,192 KB
testcase_19 AC 2 ms
4,152 KB
testcase_20 AC 2 ms
4,240 KB
testcase_21 AC 2 ms
4,168 KB
testcase_22 AC 2 ms
4,216 KB
testcase_23 AC 2 ms
4,268 KB
testcase_24 AC 2 ms
4,248 KB
testcase_25 AC 2 ms
4,264 KB
testcase_26 AC 2 ms
4,184 KB
testcase_27 AC 2 ms
4,208 KB
testcase_28 AC 2 ms
4,320 KB
testcase_29 AC 2 ms
4,200 KB
testcase_30 AC 2 ms
4,416 KB
testcase_31 AC 2 ms
4,152 KB
testcase_32 AC 2 ms
4,156 KB
testcase_33 AC 2 ms
4,196 KB
testcase_34 AC 2 ms
4,204 KB
testcase_35 AC 2 ms
4,232 KB
testcase_36 AC 2 ms
4,216 KB
testcase_37 AC 2 ms
4,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.2.2/environments/default
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking a.out ...

ソースコード

diff #

import Control.Applicative
import Data.List
import Data.Ratio

main :: IO ()
main = solve <$> (getLine >> f) <*> (getLine >> f) >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> [Int] -> String
solve (a:as) bs = let n = foldl' (\x y -> x * (1 % y)) (a % 1) as
                      (b':bs') = reverse bs
                      d = foldl' (\x y -> recip x * (y % 1)) (b' % 1) bs'
                      ans = n * recip d
                      in unwords . map show $ [numerator ans, denominator ans]
0