結果
問題 | No.2142 Segment Zero |
ユーザー | nonon |
提出日時 | 2024-09-23 23:14:25 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 560 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 6,979 ms |
コンパイル使用メモリ | 251,296 KB |
実行使用メモリ | 50,304 KB |
最終ジャッジ日時 | 2024-09-23 23:16:26 |
合計ジャッジ時間 | 22,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#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 = 0; 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; }