HDU 1757(数论,矩阵)
来源:互联网 发布:龟牌极限蜡怎么样 知乎 编辑:程序博客网 时间:2024/04/30 03:17
A Simple Math Problem
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 440 Accepted Submission(s): 253
Problem Description
Lele now is thinking about a simple function f(x).
If x < 10 f(x) = x.
If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);
And ai(0<=i<=9) can only be 0 or 1 .
Now, I will give a0 ~ a9 and two positive integers k and m ,and could you help Lele to caculate f(k)%m.
If x < 10 f(x) = x.
If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);
And ai(0<=i<=9) can only be 0 or 1 .
Now, I will give a0 ~ a9 and two positive integers k and m ,and could you help Lele to caculate f(k)%m.
Input
The problem contains mutiple test cases.Please process to the end of file.
In each case, there will be two lines.
In the first line , there are two positive integers k and m. ( k<2*10^9 , m < 10^5 )
In the second line , there are ten integers represent a0 ~ a9.
In each case, there will be two lines.
In the first line , there are two positive integers k and m. ( k<2*10^9 , m < 10^5 )
In the second line , there are ten integers represent a0 ~ a9.
Output
For each case, output f(k) % m in one line.
Sample Input
10 99991 1 1 1 1 1 1 1 1 120 5001 0 1 0 1 0 1 0 1 0
Sample Output
45104此题矩阵的幂求解要用到快速求幂~ 有点类似求斐波那契数列!
- HDU 1757(数论,矩阵)
- HDU 2254(数论,矩阵)
- HDU 2276(数论,构造二分矩阵)
- HDU 2842(数论,构造矩阵)
- HDU 2256(数论,构造二分矩阵)
- HDU 2254 奥运(数论+矩阵)
- HDU 2971(数论,构造矩阵+矩阵乘法优化)
- HDU 2855(数论,构造矩阵+矩阵乘法)
- HDU 1575(数论,矩阵乘法+求幂)
- hdu 5451 Best Solver(矩阵乘法+数论)
- HDU 2256 Problem of Precision(矩阵快速幂 数论 )
- HDU 5667 Sequence(数论+矩阵快速幂)
- HDU 3802 Ipad,IPhone 数论 矩阵乘法
- hdu 1757(矩阵)
- HDU 2204 (数论)
- hdu 1722(数论)
- hdu 1492(数论)
- hdu 2554 (数论)
- struts2学习笔记(一)
- Android 无线启动过程分析 无线启动过程分析
- 学生管理系统小感
- 最简单的CI框架入门示例--数据库取数据
- Cuckoo Hashing
- HDU 1757(数论,矩阵)
- 测试员与开发员的区别
- 例子:BlackBerry真正的后台运行程序,Task里面看不到的哦
- 传谷歌预推新手机 Nexus Two下月发布
- 汇编 数据结构--数组
- 北京的六条经典徒步线路
- FTP两种工作模式:主动模式(Active FTP)和被动模式
- 跨dll,针对Vector引用的传递没有问题,但是Map就出现问题了
- [软件人生]抢钱的电影与现在的软件开发