結果
問題 |
No.1304 あなたは基本が何か知っていますか?私は知っています.
|
ユーザー |
|
提出日時 | 2020-12-02 21:06:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 167,528 KB |
実行使用メモリ | 350,112 KB |
最終ジャッジ日時 | 2025-06-22 03:00:56 |
合計ジャッジ時間 | 69,784 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 WA * 9 TLE * 21 -- * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) ll MOD = 998244353; ll dp[41][1040][1040]; void add(ll &a, ll b) { a = (a+b) % MOD; } int main() { int n, k, x, y; cin >> n >> k >> x >> y; set<int> s; rep(i, k) { int a; cin >> a; s.insert(a); } memset(dp, 0, sizeof(dp)); int mn = 1030; dp[0][0][0] = 1; rep(i, n) { rep(j, mn) { ll sum = 0; rep(t, mn) add(sum, dp[i][j][t]); if(sum == 0) continue; for(int l : s) { add(sum, -dp[i][j][l]); add(dp[i+1][j^l][l], sum); add(sum, dp[i][j][l]); } } } ll ans = 0; for(int i = x; i <= min(mn, y); i++) for(int j : s) add(ans, dp[n][i][j]); add(ans, MOD); cout << ans << endl; }