比赛 |
国庆欢乐赛2 |
评测结果 |
TAAAAAAAATTTTTTTATTT |
题目名称 |
毛一琛 |
最终得分 |
45 |
用户昵称 |
陆晨洗 |
运行时间 |
34.306 s |
代码语言 |
C++ |
内存使用 |
3.51 MiB |
提交时间 |
2025-10-04 09:38:28 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n,ans,sum;
bool b;
int t[50]={0};
int a[50];int a1;
void dfs2(int x,int y,int z)
{
int i;
if(b==true)
{
return;
}
if(y==z/2)
{
ans++;
b=true;
return;
}
if(y>z/2||x==a1+1)
{
return;
}
dfs2(x+1,y+a[x],z);
dfs2(x+1,y,z);
return;
}
void dfs1(int x,int y)
{
int i;
if(x>=n+1)
{
if(y%2==1||a1<=1)
{
return;
}
b=false;
dfs2(1,0,y);
return;
}
a1++;
a[a1]=t[x];
dfs1(x+1,y+t[x]);
a1--;
dfs1(x+1,y);
return;
}
int main()
{
freopen("subsets.in","r",stdin);
freopen("subsets.out","w",stdout);
int i,j;
cin>>n;
a1=0;
for(i=1;i<=n;i++)
{
cin>>t[i];
sum=sum+t[i];
}
dfs1(1,0);
cout<<ans;
return 0;
}