結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー KKT89
提出日時 2020-12-01 02:58:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 201,072 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-22 02:29:03
合計ジャッジ時間 8,231 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45 RE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

constexpr ll mod=998244353;

ll dp[41][1024];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k,x,y; cin >> n >> k >> x >> y;
	vector<int> a(k);
	for(int i=0;i<k;i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()),a.end());
	k=a.size();
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<1024;j++){
			for(int K:a){
				(dp[i+1][j^K]+=dp[i][j])%=mod;
			}
			if(i+2<=n){
				if(i==0){
					(dp[i+2][j]-=dp[i][j]*k)%=mod;
				}
				else{
					(dp[i+2][j]-=dp[i][j]*(k-1))%=mod;
				}
			}
		}
	}
	ll res=0;
	for(int i=0;i<1024;i++){
		if(x<=i and i<=y){
			res+=dp[n][i];
			res%=mod;
		}
	}
	if(res<0)res+=mod;
	cout << res << endl;
}
0