結果
問題 | No.648 お や す み |
ユーザー | ats5515 |
提出日時 | 2018-02-09 22:43:51 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 748 ms |
コンパイル使用メモリ | 81,604 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 20:58:53 |
合計ジャッジ時間 | 2,793 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); unsigned long long N; cin >> N; //N = (unsigned long long)((unsigned long long)2000000000 * (2000000000 - 1))/2; //cerr << 2 * N << endl; unsigned long long u = (2 * 1000000000ull) + 5; unsigned long long d = 0; unsigned long long m; while (u != 1 + d) { m = (u + d) / 2; if (m*(m + 1) <= 2 * N) { d = m; } else { u = m; } //cerr << m*(m+1) << endl; } m = d; if (N == 1) { cout << "YES" << endl; cout << 1 << endl; } else { if (m*(m + 1) == 2 * N) { cout << "YES" << endl; cout << m << endl; } else { cout << "NO" << endl; } } }