結果

問題 No.648  お や す み 
ユーザー Kutimoti_T
提出日時 2018-05-27 10:12:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 1,155 ms
コンパイル使用メモリ 158,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 18:24:41
合計ジャッジ時間 3,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 53 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 n;

int main(){
  cin >> n;

  i64 l = 1;
  i64 r = (i64)1e15;

  while(r - l > 1){
    i64 m = (l + r) / 2;
    if((m) * (m + 1) / 2 > n){
      r = m;
    }
    else{
      l = m;
    }
  }
  if(l * (l + 1) / 2 == n){
    cout << "YES" << endl << l << endl;
  }
  else{
    cout << "NO" << endl;
  }

}
0