矩阵快速幂原来还可以这么用?? 你们城里人还真会玩. 我们令$f[i][j][k]$表示总的钱数为i,当前使用的最大面值硬币的面值为$v_j$,最小为$v_k$的方案数量. 不难发现$f[i][j][k]=\sum f[a][j][l]\times f[b][l][k] $其中$l∈[k,j],a+b=i$. 很显然,这个转移过程不就是矩阵乘法的过程吗?? 考虑到$\forall v_i>v_j$,有$gcd(v_i,v_j)=v_j$,则$f[v_i]$可以由$f[v_j]$通过矩阵乘法转移得…
fibonacci数列(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, - An alter…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 148003    Accepted Submission(s): 35976 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
描述 In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, - An alternative formula for the Fibonacci sequence is . Given…
传送门 矩阵快速幂板题,写一道来练练手. 这一次在poj做题总算没忘了改万能库. 代码: #include<iostream> #include<cstdio> #define mod 10000 #define A a[0][0] #define B a[0][1] #define C a[1][0] #define D a[1][1] using namespace std; int n; struct Matrix{int a[2][2];Matrix(){A=0,B=C=D…
题目链接  Broken Clock   中文题面链接 令$cos(xα) = f(x)$ 根据三角函数变换公式有 $f(x) = \frac{2d}{l} f(x-1) - f(x-2)$ 我们现在要求的是$l * f(t)$,把$f(t)$表示成$\frac{p}{q}$的形式 令$f(x) = \frac{g(x)}{l^{x}}$,那么$g(x) = p, l^{x} = q$ $\frac{g(x)}{l^{x}} = \frac{2d}{l} * \frac{g(x-1)}{l^{x…
题意:给一个3*n的矩阵,要求用1*2的骨牌来填满,有多少种方案? 思路: 官网题解用的仍然是矩阵快速幂的方式.复杂度O(logn*83). 这样做需要构造一个23*23的矩阵,这个矩阵自乘n-1次,再来乘以初始矩阵init{0,0,0,0,0,0,0,1}后,变成矩阵ans{x,x,x,x,x,x,x,y},y就是答案了,而x不必管. 主要在这个矩阵的构造,假设棋盘是放竖直的(即n*3),那么考虑在第i行进行填放,需要考虑到第i-1行的所有可能的状态(注意i-2行必须是已经填满了,否则第i行无…
Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … An alternative formula for the Fibonacci sequence is…
题解: 这题看起来很难...但是实际上并没有想象中的那么难 第一眼看上去不会求导公式怎么办?不要紧,题目背景非常良心的给出了题目中的导数计算公式 求完导合并同类项很恶心怎么办?不要紧,样例解释说明了不需要合并同类项(然后有许多人因为这个爆〇了) 一看这种题目形式明显就是大数据结构,外面的序列明显线段树维护,次数也可以用线段树,但是线段树套线段树容易MLE: 所以用树状数组套线段树实现 具体就是以1~n为下标建线段树,外面用树状数组维护次数,每次在树状数组上查询即可 写完过样例直接1A就是爽 代码…
Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is \frac{q}{p}(\frac{q}{p} \le \frac{1}{2})​p​​q​​(​p​​q​​≤​2​​1​​). The question is, when Bob tosses the coin kktimes, what's the probability that…