結果

問題 No.2142 Segment Zero
ユーザー Wangzyy
提出日時 2023-04-27 15:54:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,070 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 181,676 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-16 21:56:13
合計ジャッジ時間 3,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 20 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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(pre[1] + pre[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