HBC14372Prime Set题解

季陌殇 算法基础篇 48 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
Given an array ofnintegersa1,a2,...,an,we saya set{i,j}is a prime set of the given array, ifi ≠ jand ai + aj is prime. BaoBao has just found an array of nintegersa1,a2,...,anin his pocket.He would like to select at most kprime set of that array to maximize the size of the union of the selected sets. That is to say, to maximizeby carefully selecting mand p1,p2,...pm,where m≤ kand piis a prime set of the given array.Please help BaoBao calculate the maximum size of the union set.

Given an array of n integers a1,a2,...,an,we say a set {i,j}  is a prime set of the given array, if i ≠ j and ai + aj is prime. BaoBao has just found an array of n integers a1,a2,...,anin his pocket. He would like to select at most k prime set of that array to maximize the size of the union of the selected sets. That is to say, to maximize   by carefully selecting m and p1,p2,...pm, where m ≤ k and pi is a prime set of the given array. Please help BaoBao calculate the maximum size of the union set.

HBC14372Prime Set题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC14372Prime Set题解