#include <cstdio>
int m,n;
int num[25]={};
int c=0;
void f(int i, int s)
{
if(i==n)
{
if(s==m)
c++;
return;
}
f(i+1,s+num[i]);
f(i+1,s-num[i]);
}
int main()
{
scanf("%d %d",&m,&n);
for(int i=0; i<n; i++)
{
scanf("%d",&num[i]);
}
f(0,0);
printf("%d",c);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: