You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
785 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 10007;
int a[N], color[N];
int main() {
int n, m; // 纸带上格子的个数,纸带上颜色的种类数
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i]; // 纸带上编号为 i 的格子上面写的数字
for (int i = 1; i <= n; i++) cin >> color[i]; // 纸带上编号为 i 的格子染的颜色
int res = 0;
for (int x = 1; x <= n; x++) {
for (int y = x + 1; 2 * y - x <= n; y++) { // 因为y>=x+1,并且z<=n
int z = 2 * y - x;
if (color[x] == color[z]) // 如果color[x]=color[z]
res = (res + (2 * y) % mod * (a[x] + a[z]) % mod) % mod;
}
}
printf("%d\n", res);
return 0;
}