Submission #20014

#TimeUsernameProblemLanguageResultExecution timeMemory
20014xdoju카드 (kriii4_Z)C++14
0 / 100
1000 ms71872 KiB
#include <stdio.h> const int MOD = 1000000007; int mul(int x, int y){ return (long long)x * y % MOD; } int power(int x, int y){ if(y == 0) return 1; int r = power(x, y / 2); r = mul(r, r); if(y % 2 == 1) r = mul(r, x); return r; } int modinv(int x){ return power(x, MOD - 2); } int dp[3010][3010]; int comb[3010][3010]; int D[3010]; int main(){ int N, L; scanf("%d%d", &N, &L); for(int i = 1; i <= N; i++) scanf("%d", &D[i]); comb[0][0] = 1; for(int i = 1; i <= L; i++){ comb[i][0] = 1; for(int j = 1; j <= i; j++){ comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD; } } dp[0][0] = 1; for(int i = 1; i <= N; i++){ for(int j = 0; j <= L; j++){ for(int k = D[i]; k <= j; k++){ dp[i][j] += mul(dp[i - 1][j - k], comb[j][k]); dp[i][j] %= MOD; } } } int moth = power(N, L); printf("%d\n", mul(dp[N][L], modinv(moth))); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...