CF595B.Pasha and Phone

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.

Also Pasha has a number k and two sequences of length n / k (n is divisible by k) _a_1, _a_2, ..., a__n / k and _b_1, _b_2, ..., b__n / k. Let's split the phone number into blocks of length k. The first block will be formed by digits from the phone number that are on positions 1, 2,..., k, the second block will be formed by digits from the phone number that are on positions k + 1, k + 2, ..., 2·k and so on. Pasha considers a phone number good, if the i-th block doesn't start from the digit b__i and is divisible by a__i if represented as an integer.

To represent the block of length k as an integer, let's write it out as a sequence _c_1, _c_2,...,c__k. Then the integer is calculated as the result of the expression c_1·10_k - 1 + c_2·10_k - 2 + ... + c__k.

Pasha asks you to calculate the number of good phone numbers of length n, for the given k, a__i and b__i. As this number can be too big, print it modulo 109 + 7.

帕沙最近购买了一部新手机“jPager”,并开始在其中添加朋友们的电话号码。每个电话号码恰好由 nn 位数字组成。

此外,帕沙还有一个整数 kk,以及两个长度均为 n/kn/k 的序列(nn 可被 kk 整除):a1,a2,…,an/ka_1, a_2, \dots, a_{n/k} 和 b1,b2,…,bn/kb_1, b_2, \dots, b_{n/k}。我们将电话号码划分为若干长度为 kk 的块:第 11 块由电话号码中位置 1,2,…,k1, 2, \dots, k 上的数字构成;第 22 块由位置 k+1,k+2,…,2kk+1, k+2, \dots, 2k 上的数字构成;以此类推。帕沙认为一个电话号码是“好的”,当且仅当对每个 ii,第 ii 个块不以数字 bib_i 开头,且该块作为整数表示时能被 aia_i 整除。

将长度为 kk 的块表示为数字序列 c1,c2,…,ckc_1, c_2, \dots, c_k,则其对应的整数值为表达式

c1⋅10k−1+c2⋅10k−2+⋯+ckc_1 \cdot 10^{k-1} + c_2 \cdot 10^{k-2} + \dots + c_k

的计算结果。

帕沙请你计算:给定 kk、aia_i 和 bib_i 的前提下,长度为 nn 的“好”电话号码的总数。由于答案可能非常大,请输出其对 109+710^9 + 7 取模的结果。

输入格式

The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(n, 9)) — the length of all phone numbers and the length of each block, respectively. It is guaranteed that n is divisible by k.

The second line of the input contains n / k space-separated positive integers — sequence _a_1, a_2, ..., a__n / k (1 ≤ a__i < 10_k).

The third line of the input contains n / k space-separated positive integers — sequence _b_1, _b_2, ..., b__n / k (0 ≤ b__i ≤ 9).

输入的第一行包含两个整数 nn 和 kk(1 ≤ n ≤ 100 0001 ≤ n ≤ 100\,000,1 ≤ k ≤ min⁡(n, 9)1 ≤ k ≤ \min(n, 9)),分别表示所有电话号码的长度以及每个分块的长度。保证 nn 能被 kk 整除。

输入的第二行包含 n/kn/k 个用空格分隔的正整数——序列 a1, a2, ..., an/ka_1,\,a_2,\,...,\,a_{n/k}(1 ≤ ai < 10k1 ≤ a_i < 10^k)。

输入的第三行包含 n/kn/k 个用空格分隔的正整数——序列 b1, b2, ..., bn/kb_1,\,b_2,\,...,\,b_{n/k}(0 ≤ bi ≤ 90 ≤ b_i ≤ 9)。

输出格式

Print a single integer — the number of good phone numbers of length n modulo 109 + 7.

输出一个整数——长度为 nn 的“好”电话号码的个数对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    6 2
    38 56 49
    7 3 4

    输出#1

    8
  • 输入#2

    8 2
    1 22 3 44
    5 4 3 2

    输出#2

    32400

说明/提示

In the first test sample good phone numbers are: 000000, 000098, 005600, 005698, 380000, 380098, 385600, 385698.

在第一个测试样例中,好的电话号码有:000000、000098、005600、005698、380000、380098、385600、385698。

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

首页