結果
| 問題 | No.2142 Segment Zero | 
| コンテスト | |
| ユーザー |  nonon | 
| 提出日時 | 2024-09-23 22:48:57 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 574 bytes | 
| コンパイル時間 | 9,004 ms | 
| コンパイル使用メモリ | 251,032 KB | 
| 実行使用メモリ | 50,304 KB | 
| 最終ジャッジ日時 | 2024-09-23 22:59:31 | 
| 合計ジャッジ時間 | 23,391 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 33 WA * 2 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long N, K;
    cin >> N >> K;
    K = N * (N + 1) / 2 - K;
    if (K == 0) {
        cout << 0 << endl;
        return 0;
    }
    set<long> S;
    long sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += i;
        S.insert(sum);
    }
    for (long s : S) {
        if (S.count(s + K)) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 2 << endl;
}
            
            
            
        