結果

問題 No.648  お や す み 
ユーザー Yug_min_null
提出日時 2021-11-15 15:06:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 187,552 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 16:53:15
合計ジャッジ時間 4,163 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#define ll long long
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
  ll M; cin >> M;
  ll bot = 0, top = 2e9;
  while(bot+1 < top){
    ll mid = (bot+top)/2;
    ll sum = mid*(mid+1)/2;
    if(sum == M){
      cout << "YES" << endl << mid << endl;
      return 0;
    }
    if(M < sum) top = mid;
    else bot = mid;
  }
  cout << "NO" << endl;
}
0