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 ...
随机推荐
- 小偷网站工具--Teleport Ultra
可以克隆别人网站的工具 http://jingyan.baidu.com/article/219f4bf7dce58bde442d3836.html
- Mybatis 模糊查询 中文问题
IDE编码:GBK ,换成UTF-8也不行! @Testpublic void testSearchStudents() {logger.info("查询学生(带条件)");Map ...
- BZOJ2733 [HNOI2012]永无乡 【线段树合并】
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- 分布式事务 & 两阶段提交 & 三阶段提交
可以参考这篇文章: http://blog.csdn.net/whycold/article/details/47702133 两阶段提交保证了分布式事务的原子性,这些子事务要么都做,要么都不做. 而 ...
- 安卓组件service
[转]http://blog.csdn.net/ithomer/article/details/7364024 一. Service简介 Service是android 系统中的四大组件之一(Acti ...
- java细节,细的你想象不到
一. 构造方法每次都是构造出新的对象,不存在多个线程同时读写同一对象中的属性的问题,所以不需要同步 . 如果父类中的某个方法使用了 synchronized关键字,而子类中也覆盖了这个方法,默认情况下 ...
- Python3基础 nonlocal关键字 内部函数访问到外部函数的变量
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- 简单的shared_ptr实现
RT,代码参考了STL中shard_ptr的实现,基本原理是引用计数,利用Ref_cnt类来管理内存,在shared_ptr创建时创建,此后shared_ptr仅是在拷贝复制析构的过程中对引用进行修改 ...
- YII 1.0 隐藏单入口index.php 设置路由与伪静态
隐藏 index.php 保证apache配置文件httpd.conf里的LoadModulerewrite_module modules/mod_rewrite.so开启(去掉#)将相对应目录的Al ...
- Struts2框架学习(二) Action
Struts2框架学习(二) Action Struts2框架中的Action类是一个单独的javabean对象.不像Struts1中还要去继承HttpServlet,耦合度减小了. 1,流程 拦截器 ...