|
- #include <cstdio>
- int x[20],n,k;
- int judge(int n)
- {
- for(int i=2;i*i<=n;i++)
- if(n%i==0)
- return 0;
- return 1;
- }
- int cal(int left,int count,int begin,int end)
- {
- if(left==0)
- return judge(count);
- int sum=0;
- for(int i=begin;i<=end;i++)
- sum+=cal(left-1,count+x[i],i+1,end);
- return sum;
- }
- int main()
- {
- scanf("%d%d",&n,&k);
- for(int i=0;i<n;i++)
- scanf("%d",&x[i]);
- int ans=cal(k,0,0,n-1);
- printf("%d",ans);
- return 0;
- }
复制代码 |
|