結果

問題 No.648  お や す み 
ユーザー tokizo
提出日時 2019-05-24 00:26:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 167,316 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-17 09:57:52
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 69 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    long long n;
    cin >> n;

    long long ng = 0, ok = n;
    while((ok - ng) > 1){
        long long mid, t;
        mid = (ok + ng) / 2;
        t = mid * (1 + mid) / 2;
        if(t < n) ng = mid;
        else ok = mid;
    }

    if(ok * (1 + ok) / 2 == n) {
        cout << "YES" << endl;
        cout << ok << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}
0