結果
| 問題 | No.6 使いものにならないハッシュ |
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2017-05-09 12:42:40 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 5,000 ms |
| コード長 | 710 bytes |
| 記録 | |
| コンパイル時間 | 5,434 ms |
| コンパイル使用メモリ | 191,872 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2026-04-05 21:20:13 |
| 合計ジャッジ時間 | 6,623 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:11:17: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
11 | ulhash acc [] = head acc
| ^^^^
Main.hs:12:53: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
12 | ulhash acc hps = ulhash (maxhash acc (dtp [] hps)) (tail hps)
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Data.Char primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where isPrime n = null [i | i<-takeWhile (\x -> x^2 <= n) primes, mod n i == 0] main = do [k,n] <- map read . words <$> getContents let ps = dropWhile (<k) (takeWhile (<=n) primes) print (ulhash [] (map hash ps)) ulhash acc [] = head acc ulhash acc hps = ulhash (maxhash acc (dtp [] hps)) (tail hps) hash p = (until (<10) (sum . map digitToInt . show) p, p) dtp acc [] = map snd (reverse acc) dtp acc ((h,p):hps) | lookup h acc /= Nothing = map snd (reverse acc) | otherwise = dtp ((h,p):acc) hps maxhash hps1 hps2 | length hps1 > length hps2 = hps1 | length hps1 < length hps2 = hps2 | otherwise = max hps1 hps2
aimy