23 lines
484 B
C++
23 lines
484 B
C++
#include<iostream>
|
|
using namespace std;
|
|
int main(){
|
|
int n,a[51]={0},f[51][2501]={0},num=0;
|
|
cin>>n;
|
|
for(int i=1;i<=n;i++){
|
|
cin>>a[i];
|
|
num+=a[i];
|
|
}
|
|
if(num%2!=0){
|
|
cout<<"0";
|
|
return 0;
|
|
}
|
|
f[1][a[1]]=1;
|
|
for(int i=2;i<=num/2;i++){
|
|
for(int j=1;j<=num/2;j++){
|
|
f[i][j]+=f[i-1][j];
|
|
if(j+a[i]<=num/2)
|
|
f[i][j+a[i]]+=f[i-1][j];
|
|
}
|
|
}
|
|
cout<<f[n][num/2];
|
|
} |