結果

問題 No.648  お や す み 
ユーザー merom686
提出日時 2018-02-09 22:39:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 73,076 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 16:21:46
合計ジャッジ時間 2,885 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 79 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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)3 << 29, [&](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;
}
0