結果
問題 | No.499 7進数変換 |
ユーザー |
![]() |
提出日時 | 2017-04-09 11:18:07 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 7,770 ms |
コンパイル使用メモリ | 172,672 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 01:25:43 |
合計ジャッジ時間 | 8,670 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
コンパイルメッセージ
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
ソースコード
importData.Charchr,ordintToChar::Int->CharintToChar x| 0 <= x && x <= 9 = chr $ ord '0' + x| 10 <= x && x <= 35 = chr $ ord 'A' - 10 + x| otherwise = error "out of range"charToInt::Char->IntcharToInt c| '0' <= c && c <= '9' = ord c - ord '0'| 'A' <= c && c <= 'Z' = ord c - ord 'A' + 10| otherwise = error "out of range"toDecimal::Integrala=>Int->String->atoDecimal fr fx = sum $ zipWith (\a b -> a * fr' ^ b) fx' $ reverse [0..length fx' - 1]wherefx' = dropWhile (== 0) $ map (fromIntegral . charToInt) fxfr' = fromIntegral frfromDecimal'::Integrala=>a->Int->afromDecimal' fx tr| fx < tr' = fx : []| otherwise = fx `mod` tr' : fromDecimal' (fx `div` tr') trwheretr' = fromIntegral trfromDecimal::Integrala=>a->Int->StringfromDecimal fx tr = map (intToChar . fromIntegral) $ reverse $ fromDecimal' fx trmain = don <- readLnputStrLn $ fromDecimal n 7