牛客多校Round 9
Solved:1
rank:112
E. Music Game
题解说有个非简化的原题 bzoj4318
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; ll n, m; ll p[1005]; ll comb[1005][1005]; ll pow_mod(ll x, ll y) { ll res = 1; while(y) { if(y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res; } int main() { scanf("%lld%lld", &n, &m); ll inv = pow_mod(100, mod - 2); for(int i = 1; i <= n; i++) scanf("%lld", &p[i]); for(int i = 1; i <= n; i++) { comb[i][i] = p[i] * inv % mod; for(int j = i + 1; j <= n; j++) comb[i][j] = comb[i][j - 1] * p[j] % mod * inv % mod; } ll ans = 0; for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) { ll tmp = pow_mod(j - i + 1, m); (tmp *= comb[i][j]) %= mod; if(i != 1) tmp = tmp * (100 - p[i - 1]) % mod * inv % mod, tmp %= mod; if(j != n) tmp = tmp * (100 - p[j + 1]) % mod * inv % mod, tmp %= mod; (ans += tmp) %= mod; } } printf("%lld\n", ans); return 0; }