結果
| 問題 | No.648 お や す み |
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-07 00:03:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 745 bytes |
| 記録 | |
| コンパイル時間 | 784 ms |
| コンパイル使用メモリ | 70,472 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 21:15:43 |
| 合計ジャッジ時間 | 2,642 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
// No.648 お や す み
// https://yukicoder.me/problems/no/648
//
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
long long n;
cin >> n;
long long lb = 0;
long long ub = 2 * pow(10, 10);
long long found = -1;
while (lb + 1 < ub) {
long long mid = (lb + ub) / 2;
long long total = (1 + mid) * mid / 2;
if (total == n) {
found = mid;
break;
} else if (total > n)
ub = mid;
else
lb = mid;
}
if (found != -1)
cout << "YES" << endl << found << endl;
else
cout << "NO" << endl;
}
kichirb3