結果
問題 | No.648 お や す み |
ユーザー |
![]() |
提出日時 | 2022-12-21 22:38:53 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 429 bytes |
コンパイル時間 | 2,536 ms |
コンパイル使用メモリ | 203,804 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 17:06:15 |
合計ジャッジ時間 | 4,356 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
ソースコード
import std;void main() {long n;readf("%d\n", n);long f(long x) {if (x % 2 == 0) return x / 2 * (x + 1);else return (x + 1) / 2 * x;}long ok, ng = int.max.to!long;while (ng - ok > 1) {long mid = (ok + ng) / 2;(f(mid) <= n ? ok : ng) = mid;}if (f(ok) == n) {writeln("YES");ok.writeln;}else {writeln("NO");}}