QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18635#2329. Greenberg Mass ComparisonDoorKickersWA 3ms3556kbC++201.0kb2022-01-22 19:43:062022-05-06 01:56:43

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 01:56:43]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 3556kb
  • [2022-01-22 19:43:06]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
signed main() {
    auto fp = [&](int a, int n, int mod) {
        int res = 1;
        while (n) {if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;}
        return res;
    };
    auto inv = [&](int x) {
        return fp(x, mod - 2, mod);
    };
    int tt; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<int> jc(n + 5), invv(n + 5);
        jc[0] = 1;
        invv[0] = 1;
        for (int i = 1; i <= n; i++) {
            jc[i] = jc[i - 1] * i % mod;
            invv[i] = inv(jc[i]);
        }
        vector<int> B(n + 5);
        B[0] = 1;
        auto C = [&](int big, int sml) {
            return jc[big] * invv[sml] % mod * invv[big - sml] % mod;
        };
        for (int i = 1; i <= n; i++) {
            for (int k = 0; k < i; k++) {
                B[i] = C(i - 1, k) * B[k] % mod + B[i] % mod;
            }
        }
        cout << B[n] << '\n';
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3556kb

input:

100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

output:

1
2
5
15
52
203
877
4140
21147
115975
678570
4213597
27644437
190899322
382958538
480142077
864869230
1076801392
742164233
1157873311
812832668
1706900325
1546020318
1173093234
759867260
1200033049
1040680584
159122123
665114805
1272358192
365885605
744733441
1692873102
1463056346
828412002
18177561...

result:

wrong answer 18th lines differ - expected: '76801385', found: '1076801392'