結果

問題 No.648  お や す み 
ユーザー mmn15277198mmn15277198
提出日時 2021-04-17 22:35:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,313 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 174,708 KB
実行使用メモリ 6,588 KB
最終ジャッジ日時 2023-09-17 07:17:59
合計ジャッジ時間 4,578 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 4 ms
6,336 KB
testcase_02 WA -
testcase_03 AC 5 ms
6,408 KB
testcase_04 AC 4 ms
6,416 KB
testcase_05 WA -
testcase_06 AC 4 ms
6,416 KB
testcase_07 AC 4 ms
6,260 KB
testcase_08 AC 4 ms
6,340 KB
testcase_09 WA -
testcase_10 AC 4 ms
6,428 KB
testcase_11 AC 4 ms
6,260 KB
testcase_12 AC 4 ms
6,408 KB
testcase_13 AC 4 ms
6,376 KB
testcase_14 AC 4 ms
6,324 KB
testcase_15 AC 4 ms
6,428 KB
testcase_16 AC 4 ms
6,368 KB
testcase_17 AC 4 ms
6,560 KB
testcase_18 AC 4 ms
6,320 KB
testcase_19 AC 4 ms
6,288 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 4 ms
6,260 KB
testcase_31 AC 4 ms
6,320 KB
testcase_32 AC 4 ms
6,428 KB
testcase_33 AC 4 ms
6,368 KB
testcase_34 AC 4 ms
6,532 KB
testcase_35 AC 4 ms
6,284 KB
testcase_36 AC 4 ms
6,348 KB
testcase_37 AC 4 ms
6,480 KB
testcase_38 AC 4 ms
6,516 KB
testcase_39 AC 4 ms
6,472 KB
testcase_40 AC 4 ms
6,416 KB
testcase_41 AC 5 ms
6,236 KB
testcase_42 AC 4 ms
6,476 KB
testcase_43 AC 4 ms
6,316 KB
testcase_44 AC 4 ms
6,448 KB
testcase_45 AC 4 ms
6,480 KB
testcase_46 AC 4 ms
6,468 KB
testcase_47 AC 4 ms
6,336 KB
testcase_48 AC 4 ms
6,240 KB
testcase_49 AC 4 ms
6,420 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 4 ms
6,260 KB
testcase_61 AC 5 ms
6,320 KB
testcase_62 AC 4 ms
6,260 KB
testcase_63 AC 4 ms
6,284 KB
testcase_64 AC 4 ms
6,532 KB
testcase_65 AC 4 ms
6,476 KB
testcase_66 AC 4 ms
6,384 KB
testcase_67 AC 5 ms
6,260 KB
testcase_68 AC 4 ms
6,420 KB
testcase_69 AC 4 ms
6,352 KB
testcase_70 AC 4 ms
6,272 KB
testcase_71 AC 5 ms
6,488 KB
testcase_72 AC 4 ms
6,240 KB
testcase_73 AC 4 ms
6,384 KB
testcase_74 AC 4 ms
6,240 KB
testcase_75 AC 5 ms
6,496 KB
testcase_76 AC 5 ms
6,448 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define vi vector<int>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define all(x) x.begin() , x.end()
#define pb push_back
#define eb emplace_back
#define chmax(x,y) (x) = max((x) , (y))
#define chmin(x,y) (x) = min((x) , (y))
#define fi first
#define se second
#define int128 __int128

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//const int MOD = int(1e9) + 7;
//const int MOD = 998244353;
//const ll MOD = ll(1e9) + 7;
const ll MOD = 998244353;
const ld PI = 3.1415926535897932384626;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int MX = 220000;

ll modpow (ll x , ll p) {
    ll ret = 1;
    while (p) {
        if (p % 2 == 1) {
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        p /= 2;
    }
    return ret;
}

vll fact(MX);
vll factinv(MX);
void init_fact () {
    fact[0] = 1;
    for (int i = 1; i < MX; i++) {
        fact[i] = 1LL * i * fact[i - 1] % MOD;
    }
    for (int i = 0; i < MX; i++) {
        factinv[i] = modpow(fact[i] , MOD - 2);
    }
}

bool is_prime (int x) {
    if (x == 2 || x == 3 || x == 5 || x == 7) {
        return true;
    }
    for (ll i = 2; i*i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

vb prime_table(MX , true);
void init_prime() {
    for (int i = 2; i < MX; i++) {
        for (int j = i + i; j < MX; j += i) {
            prime_table[j] = false;
        }
    }
    return;
}

vector<int> factrization(ll x) {
    vector<int> ret;
    for (int i = 2; i*i <= x; i++) {
        while (x % i == 0) {
            ret.pb(i);
            x /= i;
        }
    }
    if (x > 1) ret.pb(x);
    sort(all(ret));
    return ret;
}

ll moddiv (ll a , ll b) { return a * modpow(b , MOD - 2) % MOD; }
ll modsub (ll a , ll b) { if (a >= b) return (a - b) % MOD; else return (MOD - a + b); }
ll nCk (ll n , ll k) { return ((fact[n] * factinv[k] % MOD) * factinv[n - k] % MOD); }
ll nHk (ll n , ll k) { return nCk(n - 1 + k , k); } // 仕切り- 1 + boll を並べる組み合わせ
ll gcd (ll a , ll b) { if (a < b) swap(a , b); if (a % b == 0) return b; else return gcd(b , a % b); }
ll lcm (ll a , ll b) { return a / gcd(a , b) * b; }
ll lin() { ll x; scanf("%lld" , &x); return x; }
int in() { int x; scanf("%d" , &x); return x; }
bool is_palindrome (string s) { string t = s; reverse(all(t)); return (s == t); }
void io_setup() { cout << fixed << setprecision(20); }

void solve () {
    ll n; cin >> n;
    ll ok = 5e18;
    ll ng = 0;
    ll mid;
    while (ok - ng > 1) {
        mid = (ok + ng) / 2;
        ll now = (1 + mid) * mid / 2;
        if (now == n) {
            cout << "YES" << endl;
            cout << (ll)mid << endl;
            return;
        }
        if (now > n) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << "NO" << endl;
    return;
}

int main() {
    io_setup();
    //init_fact();
    //init_prime();
    solve();
    return 0;
}





0