結果

問題 No.1189 Sum is XOR
ユーザー kotatsugamekotatsugame
提出日時 2020-08-22 16:33:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 65,800 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 10:36:11
合計ジャッジ時間 1,571 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
6,816 KB
testcase_01 AC 40 ms
6,940 KB
testcase_02 AC 39 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 AC 38 ms
6,944 KB
testcase_13 AC 34 ms
6,944 KB
testcase_14 AC 22 ms
6,944 KB
testcase_15 AC 10 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 9 ms
6,940 KB
testcase_18 AC 14 ms
6,940 KB
testcase_19 AC 29 ms
6,940 KB
testcase_20 AC 29 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

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