結果

問題 No.648  お や す み 
ユーザー keiden
提出日時 2024-09-20 21:23:08
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 6,305 ms
コンパイル使用メモリ 193,388 KB
実行使用メモリ 35,688 KB
最終ジャッジ日時 2024-09-20 21:23:35
合計ジャッジ時間 21,900 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 53 WA * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (215 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/

ソースコード

diff #

open System

let sqrtLong (n: int64) : int64 =
    if n = 0L || n = 1L then n
    else
        let mutable x0 = n / 2L
        let mutable x1 = (x0 + n / x0) / 2L
        while x1 < x0 do
            x0 <- x1
            x1 <- (x0 + n / x0) / 2L
        x0

[<EntryPoint>]
let yuki648 argv : int =
    let n = 2L * Int64.Parse(Console.ReadLine())
    let k = sqrtLong n
    if n = k * (k + 1L) then
        printfn "YES"
        printfn "%d\n" k
    else
        printfn "NO"
    0
0