結果

問題 No.648  お や す み 
コンテスト
ユーザー tak
提出日時 2018-04-12 10:02:58
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
WA  
実行時間 -
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,257 ms
コンパイル使用メモリ 211,960 KB
実行使用メモリ 34,820 KB
最終ジャッジ日時 2026-03-13 17:16:42
合計ジャッジ時間 10,713 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 53 WA * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (179 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

let rec sqrt n guess =
    let curGuess =
        match guess with
        | None    -> n / 2m
        | Some(x) -> x
    let res = n / curGuess
    let ave = (curGuess + res) / 2m
    if ave = curGuess then ave
    else sqrt n (Some(ave))

let isInt (n:decimal) =
    let str = n.ToString().Split('.')
    str.Length > 1 &&
    str.[1].ToCharArray() |> Array.forall(fun x -> x ='0')

let isValid n =
    let f n = ((sqrt (8m * n + 1m) None )-1m)/2m
    f n |> isInt
    
let n = stdin.ReadLine() |> decimal

n
|> isValid
|> function | true -> "YES" | _ -> "NO"
|> printfn "%s"
0