結果

問題 No.1189 Sum is XOR
ユーザー kenskens
提出日時 2020-08-22 16:28:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 201,988 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 10:34:01
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
5,248 KB
testcase_01 AC 42 ms
5,376 KB
testcase_02 AC 41 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 41 ms
5,376 KB
testcase_13 AC 39 ms
5,376 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 AC 15 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 35 ms
5,376 KB
testcase_20 AC 36 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 998244353;

ll Pow(ll x, ll n){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod, n/2);
  else return x * Pow(x,n-1) % mod;
}

ll mod_inverse(ll a) {
  return Pow(a,mod-2);
}

int main(){
  int n, k;
  cin >> n >> k;
  if(k > 10) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> num(1<<10);
  rep(i,n) {
    int a;
    cin >> a;
    num[a]++;
  }
  vector<vector<ll>> dp(1<<10,vector<ll>(k+1));
  dp[0][0] = 1;
  rep(i,1<<10) {
    rep(l,k) {
      rep(j,i) {
        if((i | j) == i) (dp[i][l+1] += dp[j][l]*num[i^j]) %= mod;
      }  
    }
  }
  ll ans = 0;
  rep(i,1<<10) (ans += dp[i][k]) %= mod;
  ll div = 1;
  for(ll i = 1; i <= k; i++) div *= i;
  (ans *= mod_inverse(div)) %= mod;
  cout << ans << endl; 
  return 0;
}
0