1 #include<iostream>
 2 using namespace std;
 3 int a[10001];
 4 int f(int n,int m)
 5 {
 6     if(m==0||m-a[n]==0)return 1;
 7     if(n==1&&m-a[n]!=0)return 0;
 8     else return f(n-1,m)+f(n-1,m-a[n]);
 9 }
10 int main()
11 {
12     int n,m;
13     cin>>n;
14     for(int i=1;i<=n;i++)
15     {
16         cin>>a[i];
17     }
18     cin>>m;
19     if(f(n,m)==1)
20     cout<<"yes";
21     else cout<<"no";
22     return 0;
23 }

 

相关文章:

  • 2022-01-29
  • 2021-05-23
  • 2021-12-25
  • 2021-07-26
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-07-19
  • 2021-07-21
  • 2022-12-23
  • 2021-08-16
相关资源
相似解决方案