結果

問題 No.280 歯車の問題(1)
ユーザー
提出日時 2015-09-29 19:36:29
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 513 bytes
コンパイル時間 14,684 ms
コンパイル使用メモリ 162,788 KB
実行使用メモリ 7,752 KB
最終ジャッジ日時 2023-09-27 00:22:55
合計ジャッジ時間 20,479 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,508 KB
testcase_01 AC 3 ms
7,324 KB
testcase_02 AC 3 ms
7,504 KB
testcase_03 AC 3 ms
7,416 KB
testcase_04 AC 3 ms
7,536 KB
testcase_05 AC 3 ms
7,504 KB
testcase_06 AC 2 ms
7,400 KB
testcase_07 AC 3 ms
7,728 KB
testcase_08 AC 3 ms
7,624 KB
testcase_09 AC 3 ms
7,712 KB
testcase_10 AC 3 ms
7,752 KB
testcase_11 AC 3 ms
7,292 KB
testcase_12 AC 3 ms
7,516 KB
testcase_13 AC 3 ms
7,336 KB
testcase_14 AC 3 ms
7,576 KB
testcase_15 AC 3 ms
7,648 KB
testcase_16 AC 3 ms
7,676 KB
testcase_17 AC 3 ms
7,488 KB
testcase_18 AC 3 ms
7,468 KB
testcase_19 AC 2 ms
7,452 KB
testcase_20 AC 3 ms
7,720 KB
testcase_21 AC 3 ms
7,688 KB
testcase_22 AC 3 ms
7,604 KB
testcase_23 AC 3 ms
7,524 KB
testcase_24 AC 3 ms
7,476 KB
testcase_25 AC 3 ms
7,592 KB
testcase_26 AC 3 ms
7,536 KB
testcase_27 AC 3 ms
7,596 KB
testcase_28 AC 3 ms
7,332 KB
testcase_29 AC 3 ms
7,600 KB
testcase_30 AC 3 ms
7,392 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

module Main where
import Data.Ratio
  
solve :: [Integer] -> Rational
solve [] = 1
solve [x] = 1
solve (x:y:xs) = (fromInteger y % fromInteger x) * solve (y: xs)

formatRatio :: String -> String
formatRatio [] = []
formatRatio ('%':xs) = '/':formatRatio xs
formatRatio (x:xs) = x:formatRatio xs
                 
main :: IO()
main = do 
  n <- fmap read getLine  :: IO (Int)
  zs <- fmap words getLine :: IO [String]
  let zs' = fmap read zs :: [Integer]
  let res = show $ solve zs'
  putStrLn $ formatRatio res
0