虽然给出的每个题目的概率是在模数意义下,但是一样算,至于为什么原因就是就是这样。。。。哈哈哈
#include <iostream>
#include <malloc.h>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = 2000 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
LL p[maxn];
LL dp[maxn][maxn];
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> p[i];
dp[0][0] = 1;
// 1一个题不做 做错一个的概率 是 0
// 很不抽象
for (int i = 1; i <= n; i++)
{
dp[i][0] = dp[i - 1][0] * (mod + 1 - p[i]) % mod;
// 当前题目也没做对的概率
for (int j = 1; j <= i; j++)
{
dp[i][j] = (dp[i - 1][j] * (mod + 1 - p[i]) + dp[i - 1][j - 1] * p[i]) % mod;
// 前i个题做对j个题目的概率是前i-1个题目做对j题的概率乘第i个题目不对的概率+前i-1个题做对j-1个的概率乘第i个题目做对的概率
}
}
for (int i = 0; i <= n; i++)
cout << dp[n][i] << " ";
return 0;
}