結果
| 問題 | No.128 お年玉(1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-01-07 22:40:06 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 295 bytes | 
| コンパイル時間 | 3,830 ms | 
| コンパイル使用メモリ | 174,720 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-01 10:54:52 | 
| 合計ジャッジ時間 | 4,550 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 6 WA * 15 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
Main.hs:11:21: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
11 |         digitToInt (head $ show v) * (10^dil v)
   |                     ^^^^
[2 of 2] Linking a.out
            
            ソースコード
import Data.Char (digitToInt)
import Control.Monad (replicateM)
dil :: Show a => a -> Int
dil = pred . length . show
main :: IO ()
main = do
    [n, m] <- map read <$> replicateM 2 getLine
    print $ let v = n `div` m in if v < 1000 then 0 else
        digitToInt (head $ show v) * (10^dil v)
            
            
            
        