A9096 | Divisor Tree
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ distinct integers $a_{1},a_{2},...,a_{n}$ . He tries to build a divisor tree which contains each of these numbers. That is, for each $a_{i}$ , there should be at least one vertex in the tree which contains $a_{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.
- 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 $n$ distinct integers $a_{1},a_{2},...,a_{n}$ . He tries to build a divisor tree which contains each of these numbers. That is, for each $a_{i}$ , there should be at least one vertex in the tree which contains $a_{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 $n$ ( $1<=n<=8$ ). The second line contains $n$ distinct space-separated integers $a_{i}$ ( $2<=a_{i}<=10^{12}$ ).
输出格式
Print a single integer — the minimum number of vertices in the divisor tree that contains each of the numbers $a_{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.
Sample 2. In this case you can build the following divisor tree: 
Sample 3. Note that the tree can consist of a single vertex.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted