結果
問題 |
No.1304 あなたは基本が何か知っていますか?私は知っています.
|
ユーザー |
![]() |
提出日時 | 2020-12-15 18:44:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,813 bytes |
コンパイル時間 | 3,199 ms |
コンパイル使用メモリ | 205,984 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-22 03:04:08 |
合計ジャッジ時間 | 9,938 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 RE * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) typedef long long ll; typedef long double ld; typedef pair<int,int> P; constexpr int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; constexpr int AMAX = 1024; int main() { int n, K, x, y; cin >> n >> K >> x >> y; vector<int> a(K); rep(i,K) cin >> a[i]; sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); K = (int)a.size(); vector<vector<mint>> dp(n + 1, vector<mint>(AMAX, 0)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < AMAX; j++) { for (int k = 0; k < K; k++) dp[i + 1][j] += dp[i][j ^ a[k]]; if (i == 1) dp[i + 1][j] -= dp[0][j] * K; else if (i >= 2) dp[i + 1][j] -= dp[i - 1][j] * (K - 1); } } mint res = 0; x = min(1023, x); y = min(1023, y); for ( int i = x; i <= y; i++) { res += dp[n][i]; } cout << res.x << endl; return 0; }