結果

問題 No.648  お や す み 
ユーザー tecchaxn
提出日時 2018-02-10 11:26:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 1,370 ms
コンパイル使用メモリ 158,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 21:06:26
合計ジャッジ時間 3,328 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
#define MOD 1000000007
#define SIZE 100005

using namespace std;
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int N;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>N;
    int ok=1e10,ng=0;
    while(ok-ng>1){
        int x=(ok+ng)/2;
        if(x*(x+1)/2>=N) ok=x;
        else ng=x;
    }
    if(ok*(ok+1)/2==N) cout<<"YES\n"<<ok<<endl;
    else cout<<"NO"<<endl;

}
0