CF145C.Lucky Subsequence

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has sequence a consisting of n integers.

The subsequence of the sequence a is such subsequence that can be obtained from a by removing zero or more of its elements.

Two sequences are considered different if index sets of numbers included in them are different. That is, the values of the elements do not matter in the comparison of subsequences. In particular, any sequence of length n has exactly 2_n_ different subsequences (including an empty subsequence).

A subsequence is considered lucky if it has a length exactly k and does not contain two identical lucky numbers (unlucky numbers can be repeated any number of times).

Help Petya find the number of different lucky subsequences of the sequence a. As Petya's parents don't let him play with large numbers, you should print the result modulo prime number 1000000007 (109 + 7).

佩佳非常喜欢幸运数。众所周知,幸运数是指十进制表示中仅包含幸运数字 4 和 7 的正整数。例如,47、744、4 是幸运数,而 5、17、467 不是幸运数。

佩佳有一个由 nn 个整数组成的序列 aa。

序列 aa 的一个子序列,是指通过从 aa 中删除零个或多个元素后所得到的序列。

若两个子序列所包含元素的下标集合不同,则认为它们是不同的子序列。换言之,在比较子序列时,元素的值本身并不重要。特别地,任意长度为 nn 的序列恰好有 2n2^n 个不同的子序列(包括空子序列)。

一个子序列被称为幸运子序列,当且仅当其长度恰好为 kk,且其中不包含两个相同的幸运数(非幸运数可重复任意多次)。

请帮助佩佳计算序列 aa 中不同的幸运子序列的个数。由于佩佳的父母不允许他处理过大的数,你应将结果对素数 10000000071000000007(即 109+710^9 + 7)取模后输出。

输入格式

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 105). The next line contains n integers a__i (1 ≤ a__i ≤ 109) — the sequence a.

第一行包含两个整数 nn 和 kk(1 ≤ k ≤ n ≤ 1051 \le k \le n \le 10^5)。下一行包含 nn 个整数 aia_i(1 ≤ ai ≤ 1091 \le a_i \le 10^9)——序列 aa。

输出格式

On the single line print the single number — the answer to the problem modulo prime number 1000000007 (109 + 7).

在单行中输出一个整数——该问题答案对质数 10000000071000000007(即 109+710^9 + 7)取模的结果。

输入输出样例

  • 输入#1

    3 2
    10 10 10

    输出#1

    3
  • 输入#2

    4 2
    4 4 7 7

    输出#2

    4

说明/提示

In the first sample all 3 subsequences of the needed length are considered lucky.

In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.

在第一个样例中,所有长度为所需长度的 3 个子序列都被视为幸运子序列。

在第二个样例中,共有 4 个幸运子序列。它们对应的下标集合为(下标从 1 开始):{1, 3}、{1, 4}、{2, 3} 和 {2, 4}。

输入解题思路,AI测评打分。不知道怎么写?

首页