結果
問題 | No.1189 Sum is XOR |
ユーザー |
![]() |
提出日時 | 2020-08-22 13:38:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,437 bytes |
コンパイル時間 | 1,534 ms |
コンパイル使用メモリ | 123,192 KB |
最終ジャッジ日時 | 2025-01-13 07:49:55 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; const ll MOD=998244353; ll powmod(ll a, ll k){ ll ap=a, ans=1; while(k){ if(k&1){ ans*=ap; ans%=MOD; } ap=ap*ap; ap%=MOD; k>>=1; } return ans; } ll inv(ll a){ return powmod(a, MOD-2); } ll dp[11][1<<10]; int main() { int n, k; cin>>n>>k; if(k>10){ cout<<0<<endl; return 0; } int a[200020]; for(int i=0; i<n; i++) cin>>a[i]; int cnt[1<<10]={}; for(int i=0; i<n; i++) cnt[a[i]]++; dp[0][0]=1; for(int i=1; i<(1<<10); i++){ for(int j=i; j>0; j=(j-1)&i){ for(int l=1; l<=k; l++){ dp[l][i]+=dp[l-1][i-j]*cnt[j]; dp[l][i]%=MOD; } } } ll ans=0; for(int i=0; i<(1<<10); i++) (ans+=dp[k][i])%=MOD; for(int i=2; i<=k; i++) (ans*=inv(i))%=MOD; cout<<ans<<endl; return 0; }