結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー KKT89
提出日時 2020-12-01 12:52:21
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 18,381 ms
コンパイル使用メモリ 274,652 KB
最終ジャッジ日時 2025-01-16 11:17:29
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45 RE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#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++){
			if(dp[i][j]==0)continue;
			for(int K:a){
				dp[i+1][j^K]+=dp[i][j];
			}
			if(i+2<=n){
				if(i==0){
					(dp[i+2][j]-=dp[i][j]*k);
				}
				else{
					(dp[i+2][j]-=dp[i][j]*(k-1));
				}
			}
		}
	}
	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