結果

問題 No.648  お や す み 
ユーザー phspls
提出日時 2020-04-12 17:01:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 165,832 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-22 02:43:07
合計ジャッジ時間 3,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    llong n;
    cin >> n;

    int i = (int)sqrt(n*2);
    if(n == 1) {
        cout << "YES\n";
        cout << n << "\n";
    } else if((llong)i*(i+1) / 2 == n) {
        cout << "YES\n";
        cout << i << "\n";
    } else if((llong)(i+1)*(i+2) / 2 == n) {
        cout << "YES\n";
        cout << i+1 << "\n";
    } else {
        cout << "NO\n";
    }
}
0