結果

問題 No.1876 Xor of Sum
ユーザー 杨娵隅杨娵隅
提出日時 2022-03-19 11:42:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 1,618 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 195,688 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 00:46:59
合計ジャッジ時間 10,144 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 151 ms
5,376 KB
testcase_04 AC 264 ms
5,376 KB
testcase_05 AC 32 ms
5,376 KB
testcase_06 AC 362 ms
5,376 KB
testcase_07 AC 37 ms
5,376 KB
testcase_08 AC 32 ms
5,376 KB
testcase_09 AC 239 ms
5,376 KB
testcase_10 AC 127 ms
5,376 KB
testcase_11 AC 310 ms
5,376 KB
testcase_12 AC 151 ms
5,376 KB
testcase_13 AC 227 ms
5,376 KB
testcase_14 AC 183 ms
5,376 KB
testcase_15 AC 208 ms
5,376 KB
testcase_16 AC 26 ms
5,376 KB
testcase_17 AC 330 ms
5,376 KB
testcase_18 AC 367 ms
5,376 KB
testcase_19 AC 359 ms
5,376 KB
testcase_20 AC 363 ms
5,376 KB
testcase_21 AC 355 ms
5,376 KB
testcase_22 AC 364 ms
5,376 KB
testcase_23 AC 365 ms
5,376 KB
testcase_24 AC 364 ms
5,376 KB
testcase_25 AC 371 ms
5,376 KB
testcase_26 AC 372 ms
5,376 KB
testcase_27 AC 370 ms
5,376 KB
testcase_28 AC 365 ms
5,376 KB
testcase_29 AC 359 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int inf = 1e18;
constexpr int maxn = 2e5 + 5;
constexpr int mod = 998244353;

constexpr int P = 998244353;
// assume -P <= x < 2P
int norm(int x) 
{
  if (x < 0) x += P;
  if (x >= P) x -= P;
  return x;
}
template<class T>
T qpow(T a, int b) 
{
  T res = 1;
  for (; b; b /= 2, a *= a) 
  {
    if (b % 2) res *= a;
  }
  return res;
}
struct Z
{
  int x;
  Z(int x = 0) : x(norm(x)){}
  int val()const{return x;}
  Z operator - ()const{return Z(norm(P - x));}
  Z inv()const {assert(x != 0); return qpow(*this, P - 2);}
  Z &operator *= (const Z &rhs){x = x * rhs.x % P; return *this;}
  Z &operator += (const Z &rhs){x = norm(x + rhs.x); return *this;}
  Z &operator -= (const Z &rhs){x = norm(x - rhs.x); return *this;}
  Z &operator /= (const Z &rhs){return *this *= rhs.inv();}
  friend Z operator * (const Z &lhs, const Z &rhs){Z ret = lhs; ret *= rhs; return ret;}
  friend Z operator + (const Z &lhs, const Z &rhs){Z ret = lhs; ret += rhs; return ret;}
  friend Z operator - (const Z &lhs, const Z &rhs){Z ret = lhs; ret -= rhs; return ret;}
  friend Z operator / (const Z &lhs, const Z &rhs){Z ret = lhs; ret /= rhs; return ret;}
};

inline void solve()
{
  constexpr int S = 2000 * 2000;
  int n; cin >> n;
  bitset<S + 1> f(1);
  while (n --)
  {
    int x; cin >> x;
    f ^= f << x;
  }
  int ans = 0;
  for (int i = f._Find_first(); i <= S; i = f._Find_next(i)) ans ^= i;
  cout << ans << "\n";
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
/*
The details you should care:

*/
0