아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Breeding Bugs

시간 제한1초메모리 제한1024 MB

요약
n마리 매미의 주기가 주어질 때, 남긴 매미 중 어느 두 마리의 주기 합도 소수가 되지 않도록 최대로 남길 수 있는 마릿수를 구한다.
난이도

보통10점 중 7점

유형
조합론, 그리디, 수학, 정수론
정답자
아직 제출이 없습니다

문제

This year is a good year for North America. 2022 is one of the few years where no brood of the periodical cicada is hatching and thus, no swarms will destroy the crops on the fields.

Those periodical cicadas have a somewhat strange property: They have highly synchronized life cycles, which means that almost all individuals in a local population emerge in the same year, resulting in periodical cicada plagues. Even odder is the fact that the periodicities of those life cycles appear to be prime, for example 13 or 17 years. The best theory for this so far is that a prime periodicity lets them avoid predators with shorter population cycles since a brood emergence of cicadas will rarely coincide with a predator's population boost.

But nobody likes cicada plagues, so this prime periodicity is now your problem. Your hope is that cicadas with non-prime periodicity will not be able to avoid predators anymore and that there will be fewer cicada plagues as a result. So, to prevent the next plague, you forge a plan to breed different cicada types to get a new type with non-prime periodicity. If you mate a cicada of a type with periodicity aa with another cicada of a type with periodicity bb, you assume to get a cicada of a type with periodicity a+ba+b. You have already captured nn cicadas to breed but you don't know which will mate. Therefore, you decided to set some cicadas free such that the remaining ones can mate this year in any way they want without producing a cicada of a type with prime periodicity. How many of your cicadas can you keep at most?

입력

The input consists of:

  • One line with a single integer nn (1≤n<7501\leq n<750), the number of cicadas.
  • One line with nn integers p_1,…,p_np\_1, \ldots, p\_n (1≤p_i<1071\leq p\_i<10^7), where p_ip\_i denotes the periodicity of the iith cicada.

출력

Output a single integer, the maximum number of cicadas you can keep.

예제2

  1. 예제 1

    입력
    8
    1 2 3 4 5 6 7 8
    
    예상 출력
    4
    
  2. 예제 2

    입력
    5
    7 13 2 2 4
    
    예상 출력
    4