結果

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

ソースコード

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;
    else cout << "NO" << endl;

    return 0;
}
0