?? assist.hs.txt
字號:
-- Problem Assistance Required-- Algorithm Recursion-- Runtime O(n*l(n)) where l(n) is the number of lucky numbers <= n-- Author Walter Guttmann-- Date 31.12.2001main :: IO ()main = do input <- readFile "assist.in" mapM_ solve $ takeWhile (> 0) $ map read $ words inputsolve :: Int -> IO ()solve n = print (lucky [2..] !! (n-1))lucky :: [Int] -> [Int]lucky (x:xs) = x : lucky (removeNth x x xs)removeNth :: Int -> Int -> [a] -> [a]removeNth n 1 (_:xs) = removeNth n n xsremoveNth n k (x:xs) = x : removeNth n (k-1) xs
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -