結果
| 問題 |
No.1189 Sum is XOR
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-08-22 13:17:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 744 ms / 2,000 ms |
| コード長 | 1,701 bytes |
| コンパイル時間 | 3,560 ms |
| コンパイル使用メモリ | 248,800 KB |
| 最終ジャッジ日時 | 2025-01-13 07:22:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include <bits/extc++.h>
#ifndef DUMP
#define DUMP(...) (void)0
#endif
using namespace std;
template <class T, class Op = multiplies<>>
constexpr T power(T a, uint64_t n, T init = 1, Op op = Op{}) {
while (n) {
if (n & 1) init = op(init, a);
if (n >>= 1) a = op(a, a);
}
return init;
}
template <uint32_t M>
struct modular {
using T = modular;
static constexpr uint32_t mod = M;
uint32_t v;
modular(int64_t x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
T operator-() const { return T() -= *this; }
T& operator+=(T b) { return (int)(v += b.v - mod) < 0 ? v += mod : v, *this; }
T& operator-=(T b) { return (int)(v -= b.v) < 0 ? v += mod : v, *this; }
T& operator*=(T b) { return v = (uint64_t)v * b.v % mod, *this; }
T& operator/=(T b) { return *this *= power(b, mod - 2); }
friend T operator+(T a, T b) { return a += b; }
friend T operator-(T a, T b) { return a -= b; }
friend T operator*(T a, T b) { return a *= b; }
friend T operator/(T a, T b) { return a /= b; }
friend bool operator==(T a, T b) { return a.v == b.v; }
};
using mint = modular<998244353>;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, k;
cin >> n >> k;
if (k > 10) {
cout << "0\n";
exit(0);
}
vector<array<mint, 11>> dp(1 << 10);
dp[0][0] = 1;
while (n--) {
int a;
cin >> a;
auto ndp = dp;
for (int bt = 0; bt < 1 << 10; ++bt) {
if (a & bt) continue;
for (int i = 0; i < k; ++i) {
ndp[bt | a][i + 1] += dp[bt][i];
}
}
swap(dp, ndp);
}
mint res;
for (int bt = 0; bt < 1 << 10; ++bt) res += dp[bt][k];
cout << res.v << '\n';
}
risujiroh