Submission #9602

#TimeUsernameProblemLanguageResultExecution timeMemory
9602lemonsqueezeThe last wizard (kriii2_T)C++98
1 / 4
12 ms1564 KiB
#include <stdio.h> long long t; int n, m=10, a; int p[10000]; int v[10000][10]; int l[10000]; const int MOD = 1000000007; long long comb[30][30]; long long solve (int x, long long r) { long long res = 0; if (x==n) { res = 1; for (int i=0; i<n; i++) for (int j=0; j<l[i]; j++) res = (res * p[i]) % MOD; for (int i=0; i<r; i++) res = (res * a) % MOD; for (int i=0; i<m; i++) { long long s=1; for (int j=0; j<n; j++) s = (s + v[j][i] * l[j]) % MOD; res = (res * s) % MOD; } return res; } for (int i=0; i<=r; i++) { l[x] = i; res = (res + solve (x+1, r-i) * comb[r][i]) % MOD; } return res; } int main () { scanf ("%lld%d%d", &t, &n, &a); for (int i=0; i<n; i++) { scanf ("%d", &p[i]); a -= p[i]; for (int j=0; j<10; j++) scanf ("%d", &v[i][j]); } comb[0][0] = 1; for (int i=1; i<=t; i++) { comb[i][0] = 1; for (int j=1; j<=i; j++) comb[i][j] = comb[i-1][j-1] + comb[i-1][j]; } printf ("%lld\n", solve (0, t)); return 0; } /* 1 2 3 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 10 3 22 4 1 4 2 5 0 0 0 1 0 1 7 2 0 3 2 0 7 1 0 2 0 9 0 1 0 0 1 0 1 1 7 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...