标签:
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 1E3 + 10;
const int maxp = 1E6*2 + 10;
int isnpri[maxp],a[maxn];
void getpri(){
memset(isnpri,0,sizeof(isnpri));
for(int i = 2 ; i < maxp + 10 ; ++i){
if(isnpri[i]) continue;
for(int j = i * 2 ; j < maxp; j += i){
isnpri[j] = 1;
}
}
}
int main(){
getpri();
int n,cnt1 = 0;
scanf("%d",&n);
for(int i = 0 ; i < n ; ++i){
scanf("%d",&a[i]);
if(a[i] == 1) ++cnt1;
}
if(cnt1 > 1){
for(int i = 0 ; i < n ; ++i){
if(a[i] != 1 && !isnpri[a[i] + 1]){
printf("%d\n%d",cnt1 + 1,a[i]);
for(int j = 0 ; j < cnt1;++j){
printf(" 1");
}
return 0;
}
}
printf("%d\n",cnt1);
for(int j = 0 ; j < cnt1;++j){
printf("1 ");
}
return 0;
}
for(int i = 0 ; i < n ; ++i){
for(int j = 0 ; j < n ; ++j){
if(i != j && !isnpri[a[i] + a[j]]){
printf("2\n%d %d",a[i] , a[j]);
return 0;
}
}
}
printf("1\n%d",a[0]);
return 0;
}
[2016-04-27][codeforces][665D - Simple Subset]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/e9f833b07850fa424f923009a4f2ee6d.html