20分,暴力枚举,大家教教我
查看原帖
20分,暴力枚举,大家教教我
715760
War_GodO_oBrother楼主2023/3/26 19:49
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	long long sb=0;
	cin>>n>>m;
	int a[n],b[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int x=1;x<=n;x++){
		for(int y=x+1;y<=n;y++){
			for(int z=y+1;z<=n;z++){
				if(x<y<z&&(y-x)==(z-y)&&b[x]==b[z]){
					sb=sb+(x+z)*(a[x]+a[z]);
					//cout<<x<<" "<<y<<" "<<z<<" "<<sb<<endl;
				}
			}
		}
	}
	cout<<sb%10007;
	return 0;
}
2023/3/26 19:49
加载中...