看来好几个大佬的提交,我的还算蛮简洁的
本人初学者,大佬们看个乐子。欢迎大佬们讨论传授经验━(`∀´)ノ亻!
module Main where
main :: IO ()
main = do
read <$> getLine >>= putStrLn . getAnswer 1
getAnswer :: Int -> Int -> String
getAnswer layer rest =
if rest > layer
then getAnswer (layer + 1) (rest - layer)
else
if layer `mod` 2 == 0
then shows rest . showChar '/' . show $ (layer + 1 - rest)
else shows (layer + 1 - rest) . showChar '/' . show $ rest