zoukankan      html  css  js  c++  java
  • Functional Programming Contest

    比赛链接

    A题

    1 -- Enter your code here. Read input from STDIN. Print output to STDOUT
    2 main = do
    3     x <- getLine
    4     y <-  getLine
    5     putStrLn $ reverse $ foldl (acc (x, y) -> [y]++[x]++acc) [] $ zip x y

    B题

    1 -- Enter your code here. Read input from STDIN. Print output to STDOUT
    2 import Data.List
    3 main = do
    4     inputdata <- getLine
    5     putStrLn . concat . map (xs -> f (head xs) (length xs)) . group $ inputdata 
    6         where 
    7             f ch len
    8                 | len == 1 = [ch]
    9                 | otherwise = [ch] ++ show len

    C题

     1 -- Enter your code here. Read input from STDIN. Print output to STDOUT
     2 import Data.Char
     3 main::IO ()
     4 main = getContents >>= print . ([n, k] -> superDigit ((read k) * getStrSum(n))) . words
     5 
     6 superDigit::Int -> Int
     7 superDigit n
     8     | n < 10 = n
     9     | otherwise = superDigit . getSum $ n
    10 
    11 getSum::Int -> Int
    12 getSum 0 = 0
    13 getSum n  = (n `rem` 10) + getSum ( n `div` 10)
    14 
    15 getStrSum::String -> Int
    16 getStrSum [] = 0
    17 getStrSum (x:xs) = ord x - ord '0' + getStrSum xs 

    D题

    E题

  • 相关阅读:
    MySQL大数据分页调优实践
    CentOS 搭建L2TP
    CentOS 搭建SS5
    CentOS 搭建PPTP
    CentOS 防火墙 firewalld
    CentOS 初始化账号
    nginx升级与回退
    Python
    python
    linux
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3977844.html
Copyright © 2011-2022 走看看