結果
| 問題 |
No.164 ちっちゃくないよ!!
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2017-02-04 01:24:08 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 792 bytes |
| コンパイル時間 | 2,899 ms |
| コンパイル使用メモリ | 168,832 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-12-24 06:06:07 |
| 合計ジャッジ時間 | 3,815 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Numeric
import Data.Char
import Control.Monad
intToChar :: Int -> Char
intToChar x
| 0 <= x && x <= 9 = chr $ ord '0' + x
| 10 <= x && x <= 35 = chr $ ord 'A' - 10 + x
charToInt :: Char -> Int
charToInt c
| '0' <= c && c <= '9' = ord c - ord '0'
| 'A' <= c && c <= 'Z' = ord c - ord 'A' + 10
toDecimal :: Integral a => Int -> String -> a
toDecimal fr fx = sum $ zipWith (\a b -> a * fr' ^ b) fx' $ reverse [0..length fx' - 1]
where
fx' = dropWhile (== 0) $ map (fromIntegral . charToInt) fx
fr' = fromIntegral fr
solve :: Integral a => [String] -> a
solve xs = minimum $ zipWith toDecimal minrs xs
where
minrs = map ((+ 1) . charToInt . maximum) xs
main = do
n <- readLn
vs <- replicateM n getLine
print $ solve vs
くれちー