#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //用ll代替long long
ll sum = 0;
ll n,m;
int main(){
cin>>n>>m;
ll number[n+1],color[n+1];
for(ll i = 1;i <= n;i++)cin>>number[i];
for(ll i = 1;i <= n;i++)cin>>color[i];
for(ll x = 1;x <= n-2;x++)
for(ll y = x+1;y <= n-1;y++) //枚举 x 和 y
if(color[x] == color[y+(y-x)]){ //用 (y+(y-x)) 代表 z
sum = sum + (x + (y + (y - x))) * (number[x] + number[y+(y-x)]);
}
cout<<sum % 10007; //无法通过实例2
return 0;
}
全部评论
(1) 回帖