結果

問題 No.648  お や す み 
ユーザー vjudge1
提出日時 2025-09-16 06:54:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 1,397 ms
コンパイル使用メモリ 162,328 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-16 06:54:30
合計ジャッジ時間 4,175 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  int l = 0, r = 3001001001;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (m * (m + 1) / 2 <= n)
      l = m;
    else
      r = m;
  }
  if (l * (l + 1) / 2 == n) {
    cout << "YES" << endl;
    cout << l << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
0