結果

問題 No.648  お や す み 
ユーザー Ogtsn99
提出日時 2019-10-23 16:00:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 1,187 ms
コンパイル使用メモリ 165,852 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 12:53:48
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 69 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n; cin>>n;
    int l = 0, r = INF;
    while( r - l > 1LL){
        int i = (l+r)/2LL;
        int res = i*(i+1LL)/2LL;
     
        if(res > n) r = i;
        else if(res < n) l = i;
        else {
            cout<<"YES"<<endl;
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}
0