結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー Haar
提出日時 2016-05-12 13:19:01
言語 Haskell
(9.14.1 + ACL)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 47 ms / 2,000 ms
+ 412µs
コード長 673 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,976 ms
コンパイル使用メモリ 195,072 KB
実行使用メモリ 27,776 KB
最終ジャッジ日時 2026-09-16 20:06:27
合計ジャッジ時間 6,552 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/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 #
raw source code

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