Files
python/TangDou/CSP-J/AcWingTraining/T6/463_BruteForce.cpp

25 lines
785 B
C++
Raw Permalink Normal View History

2025-08-30 18:35:01 +08:00
#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;
}