結果
| 問題 | No.105 arcの六角ボルト |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-02-28 19:52:57 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 205 ms / 5,000 ms |
| コード長 | 604 bytes |
| 記録 | |
| コンパイル時間 | 5,793 ms |
| コンパイル使用メモリ | 192,512 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2026-04-11 16:59:35 |
| 合計ジャッジ時間 | 6,804 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
コンパイルメッセージ
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:37: 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 | computeAngle = f . toDeg . (+ pi) . head . sort . map phase
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>))
import Control.Monad (replicateM, replicateM_)
import Data.Complex (Complex(..), phase)
import Data.List (sort)
import Text.Printf (printf)
toDeg :: Double -> Double
toDeg = (/ pi) . (* 180)
computeAngle :: [Complex Double] -> Double
computeAngle = f . toDeg . (+ pi) . head . sort . map phase
where f x = if x > 55.0 then 0.0 else x
main :: IO ()
main = do
t <- readLn
replicateM_ t $ do
_ <- getLine
ps <- map ((\(x : y : _) -> x :+ y) .
map read . words) <$> replicateM 6 getLine
printf "%.16f\n" (computeAngle ps)
はむ吉🐹