結果
問題 |
No.648 お や す み
|
ユーザー |
![]() |
提出日時 | 2018-04-12 10:08:12 |
言語 | F# (F# 4.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 632 bytes |
コンパイル時間 | 15,034 ms |
コンパイル使用メモリ | 194,124 KB |
実行使用メモリ | 36,408 KB |
最終ジャッジ日時 | 2024-09-13 21:35:32 |
合計ジャッジ時間 | 28,451 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 82 WA * 2 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (366 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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 let res = f n if res |> isInt then printfn "YES" printfn "%i" <| (int res) else printfn "NO" let n = stdin.ReadLine() |> decimal n |> isValid