2012-09-12から1日間の記事一覧

Codeforces 122B - B. Lucky Substring

122B - B. Lucky Substring calc :: String -> Int calc s | n4+n7 == 0 = -1 | otherwise = if n4 >= n7 then 4 else 7 where n4 = sum [1 | c <- s, c == '4'] n7 = sum [1 | c <- s, c == '7'] main = do s <- getLine print $ calc s

Codeforces 122A - A. Lucky Division

122A - A. Lucky Division isLucky :: Int -> Bool isLucky n = show n == filter (\c -> c == '4' || c == '7') (show n) calc :: Int -> String calc n = if null [i | i <- [1..n], isLucky i, n `mod` i == 0] then "NO" else "YES" main = do s <- getL…