結果

問題 No.2062 Sum of Subset mod 999630629
ユーザー kotatsugamekotatsugame
提出日時 2022-08-26 22:50:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 718 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 70,900 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2024-04-22 00:54:25
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,632 KB
testcase_01 AC 3 ms
5,504 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 3 ms
5,632 KB
testcase_04 AC 3 ms
5,504 KB
testcase_05 AC 2 ms
5,632 KB
testcase_06 AC 3 ms
5,632 KB
testcase_07 AC 3 ms
5,632 KB
testcase_08 AC 25 ms
6,144 KB
testcase_09 AC 21 ms
6,016 KB
testcase_10 AC 19 ms
5,888 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 27 ms
6,016 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 17 ms
6,016 KB
testcase_24 AC 17 ms
5,888 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
const int M=999630629;
int N;
int A[1<<17];
int cnt[10001];
mint dp[400000];
mint C[1<<17];
main()
{
	cin>>N;
	int sum=0;
	mint ans=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		sum+=A[i];
		ans+=A[i];
		cnt[A[i]]++;
	}
	ans*=mint(2).pow(N-1);
	if(sum>=M)
	{
		int rest=sum-M;
		dp[rest]++;
		for(int i=1;i<=10000&&i<=rest;i++)if(cnt[i]>0)
		{
			C[0]=1;
			for(int k=1;k<=cnt[i];k++)C[k]=C[k-1]*(cnt[i]-k+1)/k;
			for(int j=i;j<=rest;j++)for(int k=1;k<=cnt[i];k++)
			{
				dp[j-i*k]+=dp[j]*C[k];
			}
		}
		mint del=0;
		for(int i=0;i<=rest;i++)del+=dp[i];
		ans-=del*M;
	}
	cout<<ans.val()<<endl;
}
0