Codeforces 1A - A. Theatre Square

1A - A. Theatre Square

calc n m a = x * y
  where
    x = (n `div` a) + (signum $ n `mod` a)
    y = (m `div` a) + (signum $ m `mod` a)

main = do s <- getLine
          let [n, m, a] = map read $ words s :: [Integer]
          print $ calc n m a

signumを括弧で囲まないとエラーになります。:info で優先順位を確認出来ます。

Prelude> :info +
class Num a where
  (+) :: a -> a -> a
  ...
  	-- Defined in `GHC.Num'
infixl 6 +
Prelude> :info $
($) :: (a -> b) -> a -> b 	-- Defined in `GHC.Base'
infixr 0 $

参考: