CF402D Upgrading Array

题目描述

给一个有 $n$ 个数 $a[1],a[2],\dots,a[n]$ 的数列打分,你认为 $b[1],b[2]…,b[m]$ 是不好的质数。定义这个序列的分值为各个数的分值之和,设 $x$ 的分值为 $f(x)$,则 $f(x)=f(x/p)+k$。其中 $p$ 为 $x$ 的最小质因子;若 $p$ 为不好的质数, $k$ 取 $−1$ ,否则 $k$ 取 $+1$;边界条件为 $f(1)=0$。 你想让序列的分值更大,可以反复进行一项操作:让 $a[1],a[2],a[3],...,a[i](i\le n)$ 中的每个数除以它们的最大公约数。请问你能让序列的得分最大为多少。

输入格式

首行两个整数$n,m(1

输出格式

一个数 $s$ ,就是你能让序列得分的最大值。

说明/提示

Note that the answer to the problem can be negative. The GCD( $ x_{1} $ , $ x_{2} $ , ..., $ x_{k} $ ) is the maximum positive integer that divides each $ x_{i} $ .