我想大声告诉你

因为每个人都是无编号且每次随机选。

所以可以考虑将所有人编号,按照编号从小到大选。

定义 f[i][j] 表示第 i 个人没 si 且被攻击了 j 次,那么可以很容易列出状态转移方程。

code:

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2005, mod = 258280327;
int f[maxn][maxn], g[maxn], T;
inline int read()
{
    int w = 0, f = 1;
    char ch = getchar();
    while (ch < '0' or ch > '9')
    {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    while (ch >= '0' and ch <= '9')
        w = w * 10 + ch - '0', ch = getchar();
    return w * f;
}
inline int qpow(int x, int y)
{
    int cnt = 1, basic = x;
    while (y)
    {
        if (y & 1)
            cnt = cnt * basic % mod;
        basic = basic * basic % mod, y >>= 1;
    }
    return cnt;
}
signed main()
{
    T = read();
    while (T--)
    {
        int n = read(), x = read(), y = read();
        int ny = qpow(y, mod - 2);
        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= n; j++)
                f[i][j] = 0;
        for (int i = 0; i <= n; i++)
            g[i] = 0;
        f[1][0] = 1;
        g[0] = 1;
        for (int i = 1; i <= n; i++)
            g[i] = g[i - 1] * (y - x) % mod * ny % mod;
        for (int i = 2; i <= n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                f[i][j] = f[i - 1][j] * ((1 - g[j]) % mod + mod) % mod;
                if (j)
                    f[i][j] = (f[i][j] + f[i - 1][j - 1] * g[j] % mod) % mod;
            }
        }
        for (int j = 0; j < n; j++)
        {
            int ans = 0;
            for (int i = 1; i <= n; i++)
                ans = (ans + f[i][j]) % mod;
            printf("%lld ", ans * qpow(n, mod - 2) % mod);
        }
        printf("\n");
    }
    return 0;
}

 

posted @ 2018-05-04 13:58  __allenge  阅读(348)  评论(0编辑  收藏  举报