Submission #9740

#TimeUsernameProblemLanguageResultExecution timeMemory
9740coreaThe last wizard (kriii2_T)C++14
1 / 4
448 ms87456 KiB
#include <stdio.h> long long T; int N; int A; int ps[10010] = {0, }; int manas[10010][10] = {0,}; long long MOD = 1000000007LL; int next[1000010][10] = {0,}; int nextp[1000010] = {0,}; int now[1000010][10] = {0,}; int nowp[1000010] = {0,}; int nown = 1; int main(){ scanf("%lld%d%d", &T, &N, &A); int i, j, k; int psum = 0; for(i = 0; i < N; i++){ scanf("%d", &ps[i]); for(j = 0; j < 10; j++) scanf("%d", &manas[i][j]); psum += ps[i]; } ps[N] = A - psum; // N + 1th situation nowp[0] = 1; for(i = 0; i < 10; i++) now[0][i] = 1; int t; for(t = 1; t <= T; t++){ int nextn = 0; for(i = 0; i < nown; i++){ for(j = 0; j <= N; j++){ nextp[nextn] = (long long)nowp[i] * ps[j] % MOD; for(k = 0; k < 10; k++) next[nextn][k] = (now[i][k] + manas[j][k]) % MOD; nextn++; } } nown = nextn; for(i = 0; i < nown; i++){ nowp[i] = nextp[i]; for(j = 0; j < 10; j++) now[i][j] = next[i][j]; } } int sum = 0; for(i = 0; i < nown; i++){ int mult = 1; for(j = 0; j < 10; j++) mult = (long long)mult * now[i][j] % MOD; mult = (long long)mult * nowp[i] % MOD; sum += mult; sum %= MOD; } printf("%d\n", sum); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...