結果

問題 No.219 巨大数の概算
ユーザー くれちー
提出日時 2017-02-09 14:57:01
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 5,206 ms
コンパイル使用メモリ 171,648 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-12-26 02:00:52
合計ジャッジ時間 10,256 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 47 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Monad (forM_)
import Control.Applicative ((<$>))

first :: (a, b, c) -> a
first (x, _, _) = x

second :: (a, b, c) -> b
second (_, x, _) = x

third :: (a, b, c) -> c
third (_, _, x) = x

log10 :: Floating a => a -> a
log10 = logBase 10.0

solve :: Integral a => a -> a -> (a, a, a)
solve a b = (x, y, z)
    where
        a' = fromIntegral a
        b' = fromIntegral b
        t1 = b' * log10 a'
        t2 = 10.0 ** (snd . properFraction $ t1)
        x  = floor t2
        y  = floor (t2 * 10) `mod` 10
        z  = ceiling t1 - 1

main = do
    n <- readLn
    forM_ [1..n] $ \_ -> do
        [a, b] <- map read . words <$> getLine
        let ans = solve a b
        let x = first ans; y = second ans; z = third ans
        putStrLn $ show x ++ " " ++ show y ++ " " ++ show z
0