delete pics to save space
This commit is contained in:
27
history_source/挑战程序设计竞赛/2.1.4.1.cpp
Normal file
27
history_source/挑战程序设计竞赛/2.1.4.1.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include<cstdio>
|
||||
int a[22],n,k;
|
||||
bool dfs(int i,int sum)
|
||||
{
|
||||
if(i==n) return sum==k;
|
||||
if(dfs(i+1,sum)) return 1;
|
||||
if(dfs(i+1,sum+a[i])) return 1;
|
||||
return 0;
|
||||
}
|
||||
void init()
|
||||
{
|
||||
int i;
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++) scanf("%d",a+i);
|
||||
scanf("%d",&k);
|
||||
}
|
||||
void solve()
|
||||
{
|
||||
if(dfs(0,0)) printf("Yes\n");
|
||||
else printf("No\n");
|
||||
}
|
||||
int main()
|
||||
{
|
||||
init();
|
||||
solve();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user