"前缀和"
2026-07-16 20:57:33
发布于:浙江
2阅读
0回复
0点赞
我们可以不用呢
#include <bits/stdc++.h>
using namespace std;
bool f=true;
int main()
{
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int n;
cin>>n;
int a[10005];
for(int j=0;j<n;j++)
{
cin>>a[j];
}
for(int j=0;j<n;j++)
{
int h=0;
int h2=0;
f=false;
for(int k=0;k<j;k++)
{
h=h+a[k];
}
for(int k=j;k<n;k++)
{
h2=h2+a[k];
}
if(h==h2)
{
f=true;
cout<<"Yes"<<endl;
break;
}
}
if(f==false)cout<<"No"<<endl;
}
return 0;
}
这里空空如也



有帮助,赞一个