結果
問題 | No.648 お や す み |
ユーザー |
👑 |
提出日時 | 2019-04-02 23:39:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 784 bytes |
コンパイル時間 | 759 ms |
コンパイル使用メモリ | 71,452 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 13:58:39 |
合計ジャッジ時間 | 3,153 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 79 WA * 5 |
ソースコード
#include <cstdio> #include <cstdlib> #include <cstddef> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <iostream> #include <iomanip> int main(void) { long n; std::cin >> n; long min, max, mid; if(n == 1) {std::cout << "YES" << std::endl << 1 << std::endl; return 0; } min = 1; max = 1420000000;/* >= sqrt(2)*10^9 */ while(true){ mid = (min + max) / 2; long tmp = mid * (mid + 1) / 2; if(tmp == n){ std::cout << "YES" << std::endl << mid << std::endl; return 0; } if(max - min <= 1){ break; } if(tmp < n){ min = mid; } else { max = mid; } } std::cout << "NO" << std::endl; return 0; }