300765: CF145C. Lucky Subsequence

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

Description

Lucky Subsequence

题意翻译

定义幸运数为只含有$4$和$7$的数。例如: $47$, $744$, $4$ 是幸运数,而 $5$, $17$, $467$ 不是幸运数。 给定包含$n$个整数的序列$a$,试求从$a$中取出$k$个数组成一个子序列的方案数。 $a$中的数可能重复,只要位置不同就看做不同的方案。同时要求神仙数只能取用至多一次,非神仙数可以取用多次。 答案对 $10^9 + 7$ 取模。

题目描述

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 $ $ (10^{9}+7) $ .

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ $ (1<=k<=n<=10^{5}) $ . The next line contains $ n $ integers $ a_{i} $ ( $ 1<=a_{i}<=10^{9} $ ) — the sequence $ a $ .

输出格式


On the single line print the single number — the answer to the problem modulo prime number $ 1000000007 $ $ (10^{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} $ .

Input

题意翻译

定义幸运数为只含有$4$和$7$的数。例如: $47$, $744$, $4$ 是幸运数,而 $5$, $17$, $467$ 不是幸运数。 给定包含$n$个整数的序列$a$,试求从$a$中取出$k$个数组成一个子序列的方案数。 $a$中的数可能重复,只要位置不同就看做不同的方案。同时要求神仙数只能取用至多一次,非神仙数可以取用多次。 答案对 $10^9 + 7$ 取模。

加入题单

上一题 下一题 算法标签: