結果

問題 No.1189 Sum is XOR
ユーザー chocoruskchocorusk
提出日時 2020-08-22 13:38:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 1,437 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 127,864 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 08:04:14
合計ジャッジ時間 2,459 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
6,816 KB
testcase_01 AC 39 ms
6,812 KB
testcase_02 AC 41 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 9 ms
6,940 KB
testcase_12 AC 44 ms
6,944 KB
testcase_13 AC 38 ms
6,940 KB
testcase_14 AC 21 ms
6,944 KB
testcase_15 AC 11 ms
6,944 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 10 ms
6,944 KB
testcase_18 AC 15 ms
6,940 KB
testcase_19 AC 29 ms
6,940 KB
testcase_20 AC 29 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0