#abc285h. Ex - Avoid Square Number

Ex - Avoid Square Number

Score : 600600 points

问题描述

给定整数 NNKK,以及长度为 KK 的序列 EE
求满足以下条件的长度为 NN 的正整数序列的数量,结果对 109+7\color{red}{10^9+7} 取模:

  • 序列中没有平方数元素;
  • 所有元素的乘积为 i=1KpiEi\displaystyle \prod_{i=1}^{K} p_i^{E_i}

这里,

  • pip_i 表示第 ii 小的质数。
  • 两个相同长度且由正整数组成的序列 AABB 被认为是不同的,当且仅当存在某个整数 ii,使得 AABB 的第 ii 项不同。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given integers NN and KK, and a sequence EE of length KK.
Find the number, modulo 109+7\color{red}{10^9+7}, of sequences of length NN consisting of positive integers that satisfy the following conditions:

  • no element is a square number;
  • the product of all elements is i=1KpiEi\displaystyle \prod_{i=1}^{K} p_i^{E_i}.

Here,

  • pip_i denotes the ii-th smallest prime.
  • Two sequences AA and BB of the same length consisting of positive integers are considered different if and only if there exists an integer ii such that the ii-th terms of AA and BB are different.

Constraints

  • All values in the input are integers.
  • 1N,K,Ei100001 \le N,K,E_i \le 10000

Input

The input is given from Standard Input in the following format:

NN KK

E1E_1 E2E_2 \dots EKE_K

Output

Print the answer as an integer.

Sample Input 1

3 2
3 2

Sample Output 1

15

The sequences of length 33 whose total product is 72=23×3272=2^3 \times 3^2 are listed below.

  • (1,1,72)(1,1,72) and its permutations (33 instances) are inappropriate because 11 is a square number.
  • (1,2,36)(1,2,36) and its permutations (66 instances) are inappropriate because 11 and 3636 are square numbers.
  • (1,3,24)(1,3,24) and its permutations (66 instances) are inappropriate because 11 is a square number.
  • (1,4,18)(1,4,18) and its permutations (66 instances) are inappropriate because 11 and 44 are square numbers.
  • (1,6,12)(1,6,12) and its permutations (66 instances) are inappropriate because 11 is a square number.
  • (1,8,9)(1,8,9) and its permutations (66 instances) are inappropriate because 11 and 99 are square numbers.
  • (2,2,18)(2,2,18) and its permutations (33 instances) are appropriate.
  • (2,3,12)(2,3,12) and its permutations (66 instances) are appropriate.
  • (2,4,9)(2,4,9) and its permutations (66 instances) are inappropriate because 44 and 99 are square numbers.
  • (2,6,6)(2,6,6) and its permutations (33 instances) are appropriate.
  • (3,3,8)(3,3,8) and its permutations (33 instances) are appropriate.
  • (3,4,6)(3,4,6) and its permutations (66 instances) are inappropriate because 44 is a square number.

Therefore, 1515 sequences satisfy the conditions.

Sample Input 2

285 10
3141 5926 5358 9793 2384 6264 3383 279 5028 8419

Sample Output 2

672860525

Be sure to find the count modulo 109+7\color{red}{10^9+7}.

update @ 2024/3/10 11:56:46