Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Monad
- import qualified Data.ByteString.Char8 as B
- import Data.Maybe
- import Data.List
- import Control.Arrow
- readInt :: B.ByteString -> Int
- readInt = fst . fromJust . B.readInt
- main :: IO ()
- main = do
- [n] <- liftM (map readInt . B.words) B.getLine
- putStrLn "Input: "
- print n
- putStrLn "Result: "
- print (solve n)
- solve n = solve_impl n 0 0
- where solve_impl n a b | n == 0 = a
- | otherwise = solve_impl (div n 2) b (mod n 2)
- --31
Advertisement
Add Comment
Please, Sign In to add comment