結果
| 問題 |
No.1189 Sum is XOR
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 16:33:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 558 ms |
| コンパイル使用メモリ | 65,408 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 10:30:24 |
| 合計ジャッジ時間 | 1,789 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int N,K;
long dp[11][1<<10];
long cnt[1<<10];
const long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
cin>>N>>K;
if(K>10)
{
cout<<0<<endl;
return 0;
}
for(int i=0;i<N;i++)
{
int A;cin>>A;
cnt[A]++;
}
dp[0][0]=1;
for(int k=0;k<K;k++)
{
for(int i=0;i<1<<10;i++)
{
int T=1023&~i;
for(int j=T;j>0;j=j-1&T)
{
(dp[k+1][i|j]+=dp[k][i]*cnt[j])%=mod;
}
}
}
long ans=0;
for(int i=0;i<1<<10;i++)ans+=dp[K][i];
ans%=mod;
for(int i=2;i<=K;i++)ans=ans*power(i,mod-2)%mod;
cout<<ans<<endl;
}