結果

問題 No.164 ちっちゃくないよ!!
ユーザー HaarHaar
提出日時 2016-05-12 13:19:01
言語 Haskell
(9.8.2)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 11,509 ms
コンパイル使用メモリ 173,568 KB
実行使用メモリ 25,984 KB
最終ジャッジ日時 2024-04-22 14:24:13
合計ジャッジ時間 11,264 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 17 ms
11,776 KB
testcase_06 AC 65 ms
25,984 KB
testcase_07 AC 25 ms
13,824 KB
testcase_08 AC 51 ms
21,120 KB
testcase_09 AC 51 ms
21,120 KB
testcase_10 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:5:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in four further locations.
    Suggested fix: Please use spaces instead.
  |
5 |         where r = map (\x -> if x >= b then Nothing else Just x) (reverse n)
  | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Char

base :: [Integer] -> Integer -> Maybe Integer
base n b = fmap sum $ sequence $ zipWith fmap (map (*) (iterate (* b) 1)) r
	where r = map (\x -> if x >= b then Nothing else Just x) (reverse n)

minM' :: Maybe Integer -> Maybe Integer -> Maybe Integer
minM' a Nothing = a
minM' Nothing b = b
minM' a b = fmap minimum (sequence [a, b])

minM :: [Maybe Integer] -> Maybe Integer
minM [] = Nothing
minM (x:xs) = minM' x (minM xs)

main = do
	getLine
	nums <- getContents >>= return . map (map (\c -> if isDigit c then ord c - 48 else ord c - 65 + 10)) . lines
	let Just m = minM [base (map fromIntegral n) (fromIntegral b) | n <- nums, b <- [2..36]]
	print $ m
0