結果
問題 |
No.648 お や す み
|
ユーザー |
![]() |
提出日時 | 2018-09-08 17:41:41 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 856 ms |
コンパイル使用メモリ | 110,468 KB |
実行使用メモリ | 25,928 KB |
最終ジャッジ日時 | 2024-12-16 11:11:49 |
合計ジャッジ時間 | 4,480 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 83 WA * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { public static void Main() { var n = long.Parse(Console.ReadLine().Trim()); var res = search(n); if (res * (res + 1)/2L == n) { Console.WriteLine("YES"); Console.WriteLine(res); } else Console.WriteLine("NO"); } public static long search (long n) { var ng = 1L; var ok = (long)Math.Sqrt(2 * n) + 1; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2L; if (calc(mid, n)) ok = mid; else ng = mid; } return ok; } public static bool calc (long a , long n) => a * (a + 1) / 2 >= n; }