結果
| 問題 |
No.105 arcの六角ボルト
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-02-28 19:52:57 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 313 ms / 5,000 ms |
| コード長 | 604 bytes |
| コンパイル時間 | 5,152 ms |
| コンパイル使用メモリ | 174,168 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-09-24 12:08:40 |
| 合計ジャッジ時間 | 6,216 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 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 )
Main.hs:11:37: 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 | 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)
はむ吉🐹