CF337E.Divisor Tree

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A divisor tree is a rooted tree that meets the following conditions:

  • Each vertex of the tree contains a positive integer number.
  • The numbers written in the leaves of the tree are prime numbers.
  • For any inner vertex, the number within it is equal to the product of the numbers written in its children.

Manao has nn distinct integers a1,a2,...,ana_{1},a_{2},...,a_{n} . He tries to build a divisor tree which contains each of these numbers. That is, for each aia_{i} , there should be at least one vertex in the tree which contains aia_{i} . Manao loves compact style, but his trees are too large. Help Manao determine the minimum possible number of vertices in the divisor tree sought.

输入格式

The first line contains a single integer nn ( 1<=n<=81<=n<=8 ). The second line contains nn distinct space-separated integers aia_{i} ( 2<=ai<=10122<=a_{i}<=10^{12} ).

输出格式

Print a single integer — the minimum number of vertices in the divisor tree that contains each of the numbers aia_{i} .

输入输出样例

  • 输入#1

    2
    6 10
    

    输出#1

    7
    
  • 输入#2

    4
    6 72 8 4
    

    输出#2

    12
    
  • 输入#3

    1
    7
    

    输出#3

    1
    

说明/提示

Sample 1. The smallest divisor tree looks this way:

Sample 2. In this case you can build the following divisor tree:

Sample 3. Note that the tree can consist of a single vertex.

首页