B. Pasha and Phone
1 second
256 megabytes
standard input
standard output
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) a1, a2, ..., an / k and b1, b2, ..., bn / 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 bi and is divisible by ai if represented as an integer.
To represent the block of length k as an integer, let's write it out as a sequence c1, c2,...,ck. Then the integer is calculated as the result of the expression c1·10k - 1 + c2·10k - 2 + ... + ck.
Pasha asks you to calculate the number of good phone numbers of length n, for the given k, ai and bi. As this number can be too big, print it modulo 109 + 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 a1, a2, ..., an / k (1 ≤ ai < 10k).
The third line of the input contains n / k space-separated positive integers — sequence b1, b2, ..., bn / k (0 ≤ bi ≤ 9).
Print a single integer — the number of good phone numbers of length n modulo 109 + 7.
6 2
38 56 49
7 3 4
8
8 2
1 22 3 44
5 4 3 2
32400
In the first test sample good phone numbers are: 000000, 000098, 005600, 005698, 380000, 380098, 385600, 385698.
当d==0的时候就是从999999--099999
其他的时候假设d=k; 那么结果就是 999999-(k+1)00000+(k-1)99999--0;
所以随便模拟一下就行了。
B. Pasha and Phone的更多相关文章
- Codeforces Round #326 (Div. 2) B. Pasha and Phone  C. Duff and Weight Lifting
		
B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone ...
 - CF 435B Pasha Maximizes(贪心)
		
题目链接: [传送门][1] Pasha Maximizes time limit per test:1 second memory limit per test:256 megabytes ...
 - Codeforces Round #337 (Div. 2)  A. Pasha and Stick 水题
		
A. Pasha and Stick Pasha has a wooden stick of some positive integer length n. He wants to perform ...
 - Codeforces Round #337 (Div. 2) A. Pasha and Stick 数学
		
A. Pasha and Stick 题目连接: http://www.codeforces.com/contest/610/problem/A Description Pasha has a woo ...
 - Codeforces Round #311 (Div. 2)B. Pasha and Tea 水题
		
B. Pasha and Tea Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/prob ...
 - B. Pasha and String
		
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
 - Codeforces Round #330 (Div. 2) B. Pasha and Phone 容斥定理
		
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/pr ...
 - Pasha and String(思维,技巧)
		
Pasha and String Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
 - Pasha and Phone(思维)
		
Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
 - Codeforces 435B. Pasha Maximizes
		
简单贪心.... B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input s ...
 
随机推荐
- Incompatible pointer types assigning to 'id<>' from 'Class'错误
			
实例变量在类方法中被使用 原因:静态方法访问了非静态变量属性(.h中声明的那些属性),就是类方法访问了成员变量
 - Android与JNI(三) ---- c++调用java(转载)
			
源码下载:JniDemo JNI就是Java Native Interface, 即可以实现Java调用本地库, 也可以实现C/C++调用Java代码, 从而实现了两种语言的互通, 可以让我们更加灵活 ...
 - spring.net的基本搭建
			
这几天在学C#,感觉还是需要一个控制反转的框架,正好Spirng也有.net版的,看着API搭建一个 大致目录是这样的,我们在APP.CONFIG里面配好xml文件的地址,这个APP.CONFIG就相 ...
 - mysql 5.5中文乱码问题
			
一.登录MySQL查看用SHOW VARIABLES LIKE ‘character%’;下字符集,显示如下:+--------------------------+----------------- ...
 - chkdsk
			
通过 Microsoft 的相关帮助就可以明白,例如对D盘进行操作,则: 示例1:chkdsk /? 显示帮助信息. 示例2:chkdsk d: 检查D盘的磁盘状态,报告磁盘错误. 示例3:chkds ...
 - OS X EI Capitan 10.11 & xcode 7.0 beta(7A120f) -- cocoapods安装失败
			
1.sudo gem install cocoapods: ERROR:While executing gem ... (Errno:EPERM) Operation not permitted - ...
 - 转:找不到include xgpio.h;Unresolved include xgpio.h
			
这个文档讲解的是在SDK下出现的问题,如果在ISE下编译是有错的,不能正常进入SDK,那这篇文档不适合你. 问题是这样的.根据教程<XILINX FPGA Verilog编程大全>做SOC ...
 - fork() && fork() || fork()
			
http://blog.csdn.net/hs794502825/article/details/10242091 #include <unistd.h> #include <std ...
 - Struts2文件的下载
			
1.下载登录页面download.jsp 1: <%@ page language="java" contentType="text/html; charset=U ...
 - ImageView及其子类(一)
			
ImageView继承自View组件,它的主要功能是用于显示图片——实际上这个书法不太严谨因为他能显示的不仅是图片,任何Drawable对象都可以使用ImageView来显示.除此之外,ImageVi ...