結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2017-02-06 23:02:30 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 8,009 ms |
コンパイル使用メモリ | 171,520 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 08:40:46 |
合計ジャッジ時間 | 2,211 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
ソースコード
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 . reverse . dropWhile (== '0') . reverse . 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