結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2017-02-06 22:59:37 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 623 bytes |
コンパイル時間 | 4,068 ms |
コンパイル使用メモリ | 172,416 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 08:39:44 |
合計ジャッジ時間 | 5,171 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 1 |
コンパイルメッセージ
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 Data.Ratio mod2And5 :: Integral a => a -> a mod2And5 x | mod x 2 == 0 = mod2And5 (div x 2) | mod x 5 == 0 = mod2And5 (div x 5) | otherwise = x solve :: (Read a, Show a, Integral a) => a -> a -> a solve n d | mod2And5 d' > 1 = -1 | otherwise = read . (: "") . last . takeWhile (/= '0') . show $ t where d' = denominator $ n % d t = solve2 n d solve2 :: Integral a => a -> a -> a solve2 n d | mod n d == 0 = div n d | otherwise = solve2 n' d where n' = (n - d * (div n d)) * 10 main = do n <- readLn m <- readLn print $ solve n m