- A x B Problem
- 2017-08-02 18:32:47 @
并不知道如何提高运行效率……
cheng [] = 1
cheng (x:xs) = x * cheng xs
solve x = do
if x/=0
then do
print . cheng . map read . words =<< getLine
solve $ x-1
else return ()
main = do
l <- getLine
let n = read l
solve n
2 条评论
-
LKC314 LV 5 @ 2017-11-18 16:03:26
接着改,仍然t
solve :: [Integer] -> IO() solve [] = return () solve (a:b:c) = do print ( a * b ) solve c main :: IO() main = solve . tail . map read . words =<< getContents
-
2017-11-18 16:00:56@
好好学了一点Haskell之后再次写代码依然超时……
solve :: [Integer] -> [Integer] solve [] = [] solve (a:b:c) = ( a * b ) : solve c main :: IO() main = mapM_ print . solve . tail . map read . words =<< getContents
- 1