using namespace std;
int n,len;
int tot=0;
int slep[10002];
int attempt(int a){
if(len==1) return 0;
int now=slep[1];
int cnt=0;
for(int i=2;i<=len;i++){
if(now>a){
return -1;
}else if(now==a){
now=slep[i];
}else{
now+=slep[i];
cnt++;
}
}
return cnt;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>len;
tot=0;
for(int j=1;j<=len;j++){
cin>>slep[j];
}
for(int j=1;j<=len;j++) tot+=slep[j];
if(tot==0){
cout<<0<<endl;
continue;
}
for(int j=1;j<=tot;j++){
if(tot%j==0){
if(attempt(j)!=-1){
cout<<attempt(j)<<endl;
break;
}
}
}
}
}
提交记录:https://www.luogu.com.cn/record/97120766