'commit'
This commit is contained in:
25
TangDou/CSP-J/AcWingTraining/T6/463_BruteForce.cpp
Normal file
25
TangDou/CSP-J/AcWingTraining/T6/463_BruteForce.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user