Supplementary conditions :m(arry storage ) Select from within n individual . Also set Boolean array (m Individual )
Before unified setting in the future n Arrays are 1, use prev_permutation
example : Luogu 1249
#include<bits/stdc++.h> using namespace std; bool isnprimes[100000000];int
primes[10000000];int cnt,sum;int count1; int k,n; void ola(int n) { for(int
i=2;i<=n;i++) { if(isnprimes[i]==0)primes[++cnt]=i; for(int
j=1;i*primes[j]<=n;j++) { isnprimes[i*primes[j]]=1; if(i%primes[j]==0)break; }
} } int main() { scanf("%d%d",&n,&k); int arry[n+1]={0};for(int
i=1;i<=n;i++)scanf("%d",&arry[i]);int book[n+1]={0}; for(int
i=1;i<=k;i++)book[i]=1; ola(100000000); do { count1=0; for(int i=1;i<=n;i++){
if(book[i]==1)count1+=arry[i]; } if(isnprimes[count1]==0)sum++; }
while(prev_permutation(book+1,book+1+n)); printf("%d",sum); return 0; }
Technology