Submission #3713361


Source Code Expand

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int m,c[30];
long long dp[31][31][901],g[1000][1000],inv[1000];

long long com(int a,int b) {
	if(g[a][b]>=0LL)return g[a][b];
	long long ret=1LL;
	for(int i=0; i<b; i++) {
		ret=ret*(m-a-i)%mod*inv[i+1]%mod;
	}
	return g[a][b]=ret;
}

int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	m=b;
	inv[1]=1LL;
	for(int i=2; i<1000; i++) inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	for(int i=0; i<1000; i++)
		for(int j=0; j<1000; j++)
			g[i][j]=-1LL;
	for(int i=0; i<a; i++) scanf("%d",c+i);
	int ch=0;
	for(int i=0; i<a; i++) ch+=c[i];
	if(ch>b) {
		printf("0\n");
		return 0;
	}
	dp[0][0][0]=1LL;
	for(int i=0; i<a; i++)
		for(int j=0; j<=a; j++)
			for(int k=0; k<=a*30; k++) {
				if(!dp[i][j][k])continue;
				dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
				for(int l=0; l<c[i]; l++)
					dp[i+1][j+1][k+l]=(dp[i+1][j+1][k+l]+dp[i][j][k]*com(k,l))%mod;
			}
	long long ret=0LL;
	for(int i=0; i<a; i++) {
		for(int j=0; j<=a*30; j++) {
			long long v=a-i,si=b-j,val=1LL;
			while(si) {
				if(si%2) val=val*v%mod;
				v=v*v%mod;
				si/=2;
			}
			val=val*dp[a][i][j]%mod;
			if(i%2)ret=(ret+mod-val)%mod;
			else ret=(ret+val)%mod;
		}
	}
	printf("%lld\n",ret);
}

Submission Info

Submission Time
Task D - 天下一ボディービルコンテスト
User luogu_bot2
Language C++14 (GCC 5.4.1)
Score 280
Code Size 1285 Byte
Status AC
Exec Time 26 ms
Memory 14848 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&a,&b);
                     ^
./Main.cpp:26:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<a; i++) scanf("%d",c+i);
                                        ^

Judge Result

Set Name level1 level2 level3
Score / Max Score 40 / 40 100 / 100 140 / 140
Status
AC × 27
AC × 50
AC × 74
Set Name Test Cases
level1 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt
level2 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt, level2_max_0.txt, level2_maxrand_0.txt, level2_maxrand_1.txt, level2_maxrand_2.txt, level2_maxrand_3.txt, level2_maxrand_4.txt, level2_maxrand_5.txt, level2_maxrand_6.txt, level2_maxrand_7.txt, level2_maxrand_8.txt, level2_maxrand_9.txt, level2_min1_0.txt, level2_min2_0.txt, level2_rand_0.txt, level2_rand_1.txt, level2_rand_2.txt, level2_rand_3.txt, level2_rand_4.txt, level2_rand_5.txt, level2_rand_6.txt, level2_rand_7.txt, level2_rand_8.txt, level2_rand_9.txt
level3 level1_max_0.txt, level1_maxrand_0.txt, level1_maxrand_1.txt, level1_maxrand_2.txt, level1_maxrand_3.txt, level1_maxrand_4.txt, level1_maxrand_5.txt, level1_maxrand_6.txt, level1_maxrand_7.txt, level1_maxrand_8.txt, level1_maxrand_9.txt, level1_min1_0.txt, level1_min2_0.txt, level1_min3_0.txt, level1_min4_0.txt, level1_rand_0.txt, level1_rand_1.txt, level1_rand_2.txt, level1_rand_3.txt, level1_rand_4.txt, level1_rand_5.txt, level1_rand_6.txt, level1_rand_7.txt, level1_rand_8.txt, level1_rand_9.txt, level1_sample1.txt, level1_sample2.txt, level2_max_0.txt, level2_maxrand_0.txt, level2_maxrand_1.txt, level2_maxrand_2.txt, level2_maxrand_3.txt, level2_maxrand_4.txt, level2_maxrand_5.txt, level2_maxrand_6.txt, level2_maxrand_7.txt, level2_maxrand_8.txt, level2_maxrand_9.txt, level2_min1_0.txt, level2_min2_0.txt, level2_rand_0.txt, level2_rand_1.txt, level2_rand_2.txt, level2_rand_3.txt, level2_rand_4.txt, level2_rand_5.txt, level2_rand_6.txt, level2_rand_7.txt, level2_rand_8.txt, level2_rand_9.txt, level3_max_0.txt, level3_maxrand_0.txt, level3_maxrand_1.txt, level3_maxrand_2.txt, level3_maxrand_3.txt, level3_maxrand_4.txt, level3_maxrand_5.txt, level3_maxrand_6.txt, level3_maxrand_7.txt, level3_maxrand_8.txt, level3_maxrand_9.txt, level3_min1_0.txt, level3_min2_0.txt, level3_rand_0.txt, level3_rand_1.txt, level3_rand_2.txt, level3_rand_3.txt, level3_rand_4.txt, level3_rand_5.txt, level3_rand_6.txt, level3_rand_7.txt, level3_rand_8.txt, level3_rand_9.txt, level3_sample3.txt
Case Name Status Exec Time Memory
level1_max_0.txt AC 4 ms 10496 KB
level1_maxrand_0.txt AC 4 ms 10496 KB
level1_maxrand_1.txt AC 4 ms 10496 KB
level1_maxrand_2.txt AC 4 ms 10496 KB
level1_maxrand_3.txt AC 4 ms 10496 KB
level1_maxrand_4.txt AC 4 ms 10496 KB
level1_maxrand_5.txt AC 4 ms 10496 KB
level1_maxrand_6.txt AC 4 ms 10496 KB
level1_maxrand_7.txt AC 4 ms 10496 KB
level1_maxrand_8.txt AC 4 ms 10496 KB
level1_maxrand_9.txt AC 4 ms 10496 KB
level1_min1_0.txt AC 4 ms 8448 KB
level1_min2_0.txt AC 4 ms 10496 KB
level1_min3_0.txt AC 4 ms 8448 KB
level1_min4_0.txt AC 4 ms 8448 KB
level1_rand_0.txt AC 4 ms 10496 KB
level1_rand_1.txt AC 4 ms 8448 KB
level1_rand_2.txt AC 4 ms 8448 KB
level1_rand_3.txt AC 4 ms 10496 KB
level1_rand_4.txt AC 4 ms 10496 KB
level1_rand_5.txt AC 4 ms 10496 KB
level1_rand_6.txt AC 4 ms 10496 KB
level1_rand_7.txt AC 4 ms 8448 KB
level1_rand_8.txt AC 4 ms 8448 KB
level1_rand_9.txt AC 4 ms 8448 KB
level1_sample1.txt AC 4 ms 10496 KB
level1_sample2.txt AC 4 ms 10496 KB
level2_max_0.txt AC 4 ms 10496 KB
level2_maxrand_0.txt AC 4 ms 10496 KB
level2_maxrand_1.txt AC 4 ms 10496 KB
level2_maxrand_2.txt AC 4 ms 10496 KB
level2_maxrand_3.txt AC 4 ms 10496 KB
level2_maxrand_4.txt AC 4 ms 10496 KB
level2_maxrand_5.txt AC 4 ms 10496 KB
level2_maxrand_6.txt AC 4 ms 10496 KB
level2_maxrand_7.txt AC 4 ms 10496 KB
level2_maxrand_8.txt AC 4 ms 10496 KB
level2_maxrand_9.txt AC 4 ms 10496 KB
level2_min1_0.txt AC 4 ms 10496 KB
level2_min2_0.txt AC 4 ms 8448 KB
level2_rand_0.txt AC 4 ms 10496 KB
level2_rand_1.txt AC 4 ms 8448 KB
level2_rand_2.txt AC 4 ms 8448 KB
level2_rand_3.txt AC 4 ms 10496 KB
level2_rand_4.txt AC 4 ms 10496 KB
level2_rand_5.txt AC 4 ms 10496 KB
level2_rand_6.txt AC 4 ms 10496 KB
level2_rand_7.txt AC 4 ms 8448 KB
level2_rand_8.txt AC 4 ms 10496 KB
level2_rand_9.txt AC 4 ms 8448 KB
level3_max_0.txt AC 26 ms 14848 KB
level3_maxrand_0.txt AC 17 ms 14848 KB
level3_maxrand_1.txt AC 15 ms 14848 KB
level3_maxrand_2.txt AC 15 ms 14848 KB
level3_maxrand_3.txt AC 16 ms 14848 KB
level3_maxrand_4.txt AC 16 ms 14848 KB
level3_maxrand_5.txt AC 18 ms 14848 KB
level3_maxrand_6.txt AC 17 ms 14848 KB
level3_maxrand_7.txt AC 15 ms 14848 KB
level3_maxrand_8.txt AC 17 ms 14848 KB
level3_maxrand_9.txt AC 16 ms 14848 KB
level3_min1_0.txt AC 11 ms 14720 KB
level3_min2_0.txt AC 4 ms 8448 KB
level3_rand_0.txt AC 11 ms 14592 KB
level3_rand_1.txt AC 10 ms 14592 KB
level3_rand_2.txt AC 4 ms 10496 KB
level3_rand_3.txt AC 6 ms 12544 KB
level3_rand_4.txt AC 4 ms 10496 KB
level3_rand_5.txt AC 6 ms 12544 KB
level3_rand_6.txt AC 6 ms 12544 KB
level3_rand_7.txt AC 8 ms 12544 KB
level3_rand_8.txt AC 5 ms 10496 KB
level3_rand_9.txt AC 4 ms 10496 KB
level3_sample3.txt AC 5 ms 12544 KB