結果
| 問題 | No.2142 Segment Zero | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2024-04-21 16:43:52 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 302 ms / 2,000 ms | 
| コード長 | 505 bytes | 
| コンパイル時間 | 989 ms | 
| コンパイル使用メモリ | 82,404 KB | 
| 最終ジャッジ日時 | 2025-02-21 08:16:33 | 
| ジャッジサーバーID (参考情報) | judge3 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
using i64 = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    i64 N, K; cin >> N >> K;
    vector<i64> S(N+1);
    rep(i,N) S[i+1] = S[i] + (i+1);
    set<i64> Q(S.begin(), S.end());
    int ans = 2;
    rep(i,N+1) if(Q.count(K - (S[N] - S[i]))) ans = 1;
    cout << ans << '\n';
    return 0;
}
            
            
            
        