結果

問題 No.2142 Segment Zero
ユーザー WangzyyWangzyy
提出日時 2023-04-27 15:55:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 181,792 KB
実行使用メモリ 11,240 KB
最終ジャッジ日時 2024-04-28 08:14:38
合計ジャッジ時間 2,886 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,008 KB
testcase_01 AC 7 ms
11,008 KB
testcase_02 AC 5 ms
11,032 KB
testcase_03 WA -
testcase_04 AC 5 ms
11,240 KB
testcase_05 AC 6 ms
11,136 KB
testcase_06 AC 5 ms
11,020 KB
testcase_07 WA -
testcase_08 AC 5 ms
11,080 KB
testcase_09 WA -
testcase_10 AC 6 ms
11,136 KB
testcase_11 AC 6 ms
11,084 KB
testcase_12 AC 6 ms
11,084 KB
testcase_13 AC 5 ms
11,132 KB
testcase_14 AC 5 ms
11,136 KB
testcase_15 AC 7 ms
11,008 KB
testcase_16 AC 5 ms
11,008 KB
testcase_17 AC 6 ms
11,112 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 5 ms
11,136 KB
testcase_21 WA -
testcase_22 AC 7 ms
11,024 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 6 ms
11,012 KB
testcase_29 AC 6 ms
11,016 KB
testcase_30 AC 6 ms
11,136 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 5 ms
11,096 KB
testcase_36 AC 5 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>

#define ios_close std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr)

using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
#define Pi  acos(-1.0);
#define PINF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

void solve(){
    std::vector<ll> pre(1000010);
    int n;
    ll k;
    scanf("%d %lld", &n, &k);
    for(int i = 1; i <= n; i ++ ){
        pre[i] = pre[i - 1] + i;
    }
    if(pre[n] == k){
        printf("0");
        return ;
    }
    int pos = std::upper_bound(pre.begin() + 1, pre.begin() + n, k) - pre.begin() - 1;
    //printf("%d\n", pos);
    if(pre[pos] == k){
        printf("1");
    } else {
        if(1 + n == k){
            printf("1");
        } else {
            printf("2");
        }
    }
}

int main(){
#if 0
    ios_close;
#endif

#if 0
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
    int T = 1;
#if 0
    std::cin >> T;
#endif
    while(T -- ){
        solve();
    }
    return 0;
}
0