暴力解决用所有可能的值试一遍:
#include "iostream"
#include "algorithm"
using namespace std;
int main()
{
int n;
cin>>n;
char array[n+1];
getchar();
gets(array);
int b[n];
int num=0,t=0;
for (int i = 0; i < n; ++i) {
b[i]=array[i]-48;
num+=b[i];
if(b[i]>t)t=b[i];
}
int num1=0;
for (int i = t; i <=num/2; ++i) {
int x=0,y=0;
for (int j = 0; j < n; ++j) {
x+=b[j];
if(i==x){
x=0;
y++;
}
else if(x>i)break;
}
if(x==0&&y>1){
num1=1;
break;
}
}
if(num1==1)cout<<"YES";
else cout<<"NO";
return 0;
}