Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import qualified Data.List as L
- import qualified Data.Maybe as M
- splitAtDot num = (take n num, drop (n+1) num)
- where n = M.fromJust $ L.elemIndex '.' num
- findReqPower num =
- let (i, f) = splitAtDot num in
- if f == "0" then 0 else length f
- mulByPower n num =
- let (i, f) = splitAtDot num in
- case f of
- "0" -> i ++ (take n $ repeat '0') ++ ".0"
- f' -> if (n < length f') then i ++ (take n f') ++ "." ++ (drop n f')
- else i ++ f' ++ (take (n - (length f')) $ repeat '0') ++ ".0"
- readInt :: String -> Int
- readInt = read . init . init
- main = do
- nums <- words <$> getLine
- let powers = map findReqPower nums
- let power = L.maximum powers
- let listGcd = L.foldl1 gcd . map readInt . map (mulByPower power) $ nums
- let ans = (100 * 10 ^ power) `div` listGcd
- print ans
Add Comment
Please, Sign In to add comment