Created
May 6, 2012 02:49
-
-
Save pogin503/2607186 to your computer and use it in GitHub Desktop.
aizu online judge http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10001
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- import Control.Monad | |
| import Data.Int | |
| -- cubed :: String -> Integer | |
| -- cubed x = product [x, x, x] | |
| import Data.Set | |
| import Text.Printf (printf) | |
| cubed :: Int -> Int | |
| cubed x = x * x * x | |
| -- rInt :: String -> Int | |
| -- rInt = getLine | |
| stringToInt :: String -> Int | |
| stringToInt str = read str :: Int | |
| -- @see http://www.shido.info/hs/haskell8.html | |
| -- whole function to convert string to Maybe Int | |
| -- str2int :: String -> Maybe Int | |
| -- str2int "" = Nothing | |
| -- str2int str = iter (0, str) | |
| -- where iter (i, "") = Just i | |
| -- iter (i, cs) = let p = s2i (i, cs) | |
| -- in if p == Nothing | |
| -- then Nothing | |
| -- else p >>= iter | |
| main = do | |
| s <- getLine | |
| -- putStrLn $ cubed s | |
| -- putStrLn (cubed s :: Int) | |
| -- putStrLn (show (cubed s)) | |
| -- mapM print (cubed s) | |
| -- cubed ((read :: String -> Int) s) | |
| printf "%s\n" s | |
| let s1 = stringToInt s | |
| let s2 = cubed s1 | |
| printf "%d\n" s2 | |
| -- s3 <- read `fmap` readLn :: IO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment