結果

問題 No.648  お や す み 
コンテスト
ユーザー kappybar
提出日時 2026-04-26 15:02:08
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 644 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,167 ms
コンパイル使用メモリ 186,904 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-26 15:02:14
合計ジャッジ時間 3,855 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 84
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;

const double INF = 2e9;
const double EPS = 1e-8;

int main()
{
    long long n;
    cin >> n;
    long long L = 0, R = 1000000000;
    while (R - L > 1)
    {
        long long M = (R + L) / 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