結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-02-09 22:48:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 792 ms |
| コンパイル使用メモリ | 73,464 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 21:00:13 |
| 合計ジャッジ時間 | 2,571 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using I = int64_t;
template <class F>
I lower_bound(I i0, I i1, F f) {
while (i0 < i1) {
I i = (i0 + i1) / 2;
if (f(i)) i1 = i; else i0 = i + 1;
}
return i0;
}
int main() {
I n;
cin >> n;
I i = lower_bound(1, (I)1 << 31, [&](I i) {
return i * (i + 1) / 2 >= n;
});
if (i * (i + 1) / 2 == n) {
cout << "YES" << '\n' << i << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
merom686