QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446772#8526. Polygon IIucup-team3678WA 0ms4108kbC++141.9kb2024-06-17 16:04:432024-06-17 16:04:44

Judging History

你现在查看的是最新测评结果

  • [2024-06-17 16:04:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4108kb
  • [2024-06-17 16:04:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1005, M = 55, P = 1e9 + 7;

int jc[N], inv[N], pw[N], pw2[N];

int C(int x, int y) {
    return 1ll * jc[x] * inv[y] % P * inv[x - y] % P;
}

int ksm(int x, int y = P - 2) {
    int res = 1;
    while (y) {
        if (y & 1) res = 1ll * res * x % P;
        x = 1ll * x * x % P;
        y >>= 1;
    }
    return res;
}

int a[N], b[N], f[M][N];

signed main() {
    int n, mx = 0; scanf("%d", &n);
    for (int i = jc[0] = inv[0] = 1; i <= n; ++i) {
        jc[i] = 1ll * jc[i - 1] * i % P;
        inv[i] = (i == 1 ? 1 : 1ll * (P - P / i) * inv[P % i] % P);
    }
    pw2[0] = 1;
    for (int i = 1; i <= n; ++i) {
        inv[i] = 1ll * inv[i - 1] * inv[i] % P;
        pw[i] = ksm(i, n);
        pw2[i] = ksm((P + 1) >> 1, i);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        mx = max(mx, a[i]);
        for (int j = 0; j < a[i]; ++j) ++b[j];
    }
    for (int i = 1; i <= n; ++i) {
        int s = 0;
        for (int j = 0; j < i; ++j) {
            s = (s + ((j & 1) ? P - 1ll : 1ll) * C(n, j) % P * pw[i - j] % P * inv[n]) % P;
        }
        f[0][i - 1] = s;
    }
    for (int i = n - 1; i; --i) {
        f[0][i] = (f[0][i] - f[0][i - 1] + P) % P;
    }
    for (int i = 1; i <= mx; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= b[i - 1] && k <= j * 2 + 1; ++k) {
                f[i][j] = (f[i][j] + 1ll * C(b[i - 1], k) * pw2[b[i - 1]] % P * ((j * 2 - k >= 0 ? f[i - 1][j * 2 - k] : 0) + f[i - 1][j * 2 - k + 1])) % P;
            }
        }
    }
    int res = 1;
    for (int i = 0; i <= mx; ++i) {
        int t = (!i ? n : b[i - 1]) - b[i], S = 0;
        for (int j = i; j < mx; ++j) S += b[j];
        res = (res - 1ll * f[i][0] * pw2[S] % P * t % P + P) % P;
    }
    printf("%d\n", res);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3932kb

input:

3
0 2 0

output:

166666668

result:

ok 1 number(s): "166666668"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

3
0 0 0

output:

500000004

result:

ok 1 number(s): "500000004"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

3
5 6 7

output:

208333335

result:

ok 1 number(s): "208333335"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 4108kb

input:

3
0 25 50

output:

299947910

result:

wrong answer 1st numbers differ - expected: '889268532', found: '299947910'