結果

問題 No.98 円を描こう
ユーザー momen999momen999
提出日時 2017-04-15 22:15:26
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 8,700 ms
コンパイル使用メモリ 166,052 KB
実行使用メモリ 7,344 KB
最終ジャッジ日時 2023-09-25 22:26:00
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,120 KB
testcase_01 AC 2 ms
7,108 KB
testcase_02 AC 2 ms
7,088 KB
testcase_03 AC 2 ms
7,168 KB
testcase_04 AC 3 ms
7,212 KB
testcase_05 AC 3 ms
7,344 KB
testcase_06 AC 3 ms
7,304 KB
testcase_07 AC 3 ms
7,304 KB
testcase_08 AC 2 ms
7,300 KB
testcase_09 AC 2 ms
7,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

hankei r d2 | d2 == 0   = 1
            | r2 == d2    = r * 2 + 1
            | r2 > d2     = if (r*2 - 1) > d * 2 then r * 2 - 1 else r * 2
            | otherwise = hankei (r + 1) d2
            where
                r2 = r ^ 2
                d = sqrt d2

main = do
    str <- getLine
    let
        [x,y] = map read $ words str :: [Double]
        d2 = x^2 + y^2
    print $ ceiling $ hankei (max (abs x) (abs y)) d2
    
0