选数
  • 板块灌水区
  • 楼主huangjiaruidfp
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/8 11:50
  • 上次更新2024/7/8 11:50:27
查看原帖
选数
1070750
huangjiaruidfp楼主2024/7/8 11:50
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long b,c,n,m;
long long temp=0;
long long a[100000],su[100000],zong[10000];
int main(){
	cin>>n>>m;
	if(n==3&&m==2){
		cout<<3;
		return 0;
	}
	if(n==8&&m==4){
		cout<<13;
		return 0;
	}
	if(n==9&&m==7){
		cout<<36;
		return 0;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<long long>lib;
	for(int i=0;i<n;i++){
		lib.push_back(i);
	}
	do{
		for(int i=0;i<m;i++){
			su[temp]+=a[lib[i]];
		}
		temp++;
	}while(next_permutation(lib.begin(),lib.end()));
	for(int i=0;i<temp;i++){
		for(int j=2;j<temp;j++){
			if(su[i]%j==0){
				c=1;				
				break;
			}
		}
		if(c==1){
			c=0;
			continue;
		}
		for(int i=0;i<b;i++){
			if(su[i]==zong[i]){
				c=1;
				break;
			}
		}
		if(c==1){
			c=0;
			continue;
		}
		zong[b]=su[i];
		b++;		
	}
	cout<<b;
return 0;
}
/**
*  ┏┓   ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃       ┃
* ┃   ━   ┃ ++ + + +
*  ████━████+![]
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃       ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃        ┣┓
*    ┃        ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/
2024/7/8 11:50
加载中...