結果

問題 No.648  お や す み 
ユーザー dsytk7dsytk7
提出日時 2018-02-09 22:58:43
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 160,132 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 17:37:05
合計ジャッジ時間 3,865 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 79 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N;
    cin >> N;
    ll n = (sqrt(8LL*N+1)-1LL)/2LL;
    for (ll tmp = max(0LL, n-1000LL); tmp<=n+1000; ++tmp) {
        ll t1 = tmp, t2 = tmp+1;
        if (tmp%2 == 0) t1 /= 2LL;
        else t2 /= 2LL;
        if (t1*t2 == N) {
            cout << "YES" << endl;
            cout << (ll)tmp << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0