303371: CF653G. Move by Prime

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Move by Prime

题意翻译

给你一个长度为 $n$ 的数列 $a_i$,你可以进行任意次操作:将其中一个数乘上或者除以一个质数。使得最终所有数相同,并使得操作数尽可能小。现在我们想要知道 $a_i$ 的所有子序列的操作数之和是多少。答案对 $10^9+7$ 取模。 $n \leq 3 \times 10^5$。

题目描述

Pussycat Sonya has an array consisting of $ n $ positive integers. There are $ 2^{n} $ possible subsequences of the array. For each subsequence she counts the minimum number of operations to make all its elements equal. Each operation must be one of two: - Choose some element of the subsequence and multiply it by some prime number. - Choose some element of the subsequence and divide it by some prime number. The chosen element must be divisible by the chosen prime number. What is the sum of minimum number of operations for all $ 2^{n} $ possible subsequences? Find and print this sum modulo $ 10^{9}+7 $ .

输入输出格式

输入格式


The first line of the input contains a single integer $ n $ ( $ 1<=n<=300000 $ ) — the size of the array. The second line contains $ n $ integers $ t_{1},t_{2},...,t_{n} $ ( $ 1<=t_{i}<=300000 $ ) — elements of the array.

输出格式


Print the sum of minimum number of operation for all possible subsequences of the given array modulo $ 10^{9}+7 $ .

输入输出样例

输入样例 #1

3
60 60 40

输出样例 #1

6

输入样例 #2

4
1 2 3 4

输出样例 #2

24

说明

In the first sample, there are $ 8 $ possible subsequences: $ (60,60,40) $ , $ (60,60) $ , $ (60,40) $ , $ (60,40) $ , $ (60) $ , $ (60) $ , $ (40) $ and $ () $ (empty subsequence). For a subsequence $ (60,60,40) $ we can make all elements equal by two operations — divide $ 40 $ by $ 2 $ to get $ 20 $ , and then multiply $ 20 $ by $ 3 $ to get $ 60 $ . It's impossible to achieve the goal using less operations and thus we add $ 2 $ to the answer. There are two subsequences equal to $ (60,40) $ and for each of them the also need to make at least $ 2 $ operations. In each of other subsequences all numbers are already equal, so we need $ 0 $ operations for each of them. The sum is equal to $ 2+2+2=6 $ .

Input

题意翻译

给你一个长度为 $n$ 的数列 $a_i$,你可以进行任意次操作:将其中一个数乘上或者除以一个质数。使得最终所有数相同,并使得操作数尽可能小。现在我们想要知道 $a_i$ 的所有子序列的操作数之和是多少。答案对 $10^9+7$ 取模。 $n \leq 3 \times 10^5$。

加入题单

上一题 下一题 算法标签: