[Offer收割]编程练习赛49 register

Ended

Participants:177

Verdict:Accepted
Score:100 / 100
Submitted:2018-03-04 12:33:04

Lang:G++

Edit
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
#include <iostream>
using namespace std;
const int P = 1000000009;
const int MAXN = 110;
int a[MAXN], c[MAXN][MAXN];
int main() {
    ios::sync_with_stdio(false);
    c[0][0] = 1;
    for (int i = 1; i <= 100; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P;
        }
    }
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = i + 1; j <= n; j++) {
            if ((a[j] - a[i]) % k == 0) cnt++;
        }
        if (cnt >= m - 1) {
            ans = (ans + c[cnt][m- 1]) % P;
        }
    }
    cout << ans << endl;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX