Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 249    Accepted Submission(s): 140 Problem Description Farmer John likes to play mathematics games with his N cows. Recently, t…
HDU 2604 Queuing (递推+矩阵快速幂) 这位作者讲的不错,可以看看他的 #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> using namespace std; const int N = 5; int msize, Mod; struct Mat { int mat[N][N]; }; M…
题目链接:https://vjudge.net/problem/HDU-4990 Reading comprehension Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2329    Accepted Submission(s): 954 Problem Description Read the program below care…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2842 题目大意:棒子上套环.第i个环能拿下的条件是:第i-1个环在棒子上,前i-2个环不在棒子上.每个环可以取下或放上,cost=1.求最小cost.MOD 200907. 解题思路: 递推公式 题目意思非常无聊,感觉是YY的. 设$dp[i]$为取第i个环时的总cost. $dp[1]=1$,$dp[2]=2$,前两个环取下是没有条件要求的. 从i=3开始,由于条件对最后的环限制最大,所以从最后一…
题目链接 F[1] = a, F[2] = b, F[i] = 2 * F[i-2] + F[i-1] + i ^ 4, (i >= 3) 现在要求F[N] 类似于斐波那契数列的递推式子吧, 但是N最大能到int的最大值, 直接循环推解不了 所以就得用矩阵快速幂咯 现在就看转移矩阵长什么样了 Mi表示要求的矩阵 转移矩阵用A表示 A * Mi = Mi+1 矩阵Mi里面至少得有 F[i-1] F[i-2] i ^ 4 Mi+1就相应的有 F[i] F[i-1] (i+1)^4 (i+1)^4 =…
传送门:点我 Little Q wants to buy a necklace for his girlfriend. Necklaces are single strings composed of multiple red and blue beads. Little Q desperately wants to impress his girlfriend, he knows that she will like the necklace only if for every prime l…
题目链接 我们可以把棱柱拆成有\(n\)条高的矩形,尝试递推. 在计算的过程中,第\(i\)列(\(i\neq n\))只与\(i-1\)列有关,称\(i-1\)列的上面/下面为左上/左下,第\(i\)列的上面/下面为右上/右下. 我们可以发现,右上可选的颜色数与左上和右下是否同色有关,右下同理,那就记\(f[i][0/1][0/1]\)表示左上与右下是否同色,左下与右上是否同色. 但是第\(n\)列和第\(1\)列不能同色,最后怎么算答案? 不知道第\(n\)列状态算不了,所以我们还要记第\(…
http://www.lightoj.com/volume_showproblem.php?problem=1244 题意:给出六种积木,不能旋转,翻转,问填充2XN的格子有几种方法.\(N <= 10^9 \) 思路:首先手写出前几项,猜出递推式,如果真有比赛出这种题,又不能上网进工具站查是吧?N比较大显然用矩阵快速幂优化一下 /** @Date : 2016-12-18-22.44 * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : ht…
传送门:Educational Codeforces Round 60 – D   题意: 给定N,M(n <1e18,m <= 100) 一个magic gem可以分裂成M个普通的gem,现在需要N个gem,可以选择一定的magic gem,指定每一个分裂或不分裂,问一共有多少种方案 两种分裂方案不同当且仅当magic gem的数量不同,或者分裂的magic gem的索引不同. 思路: 1.首先从dp的角度出发 设F(i)为最终需要i个gem的方案数,容易得到递推式: (总方案数 = 最右边…
Happy Necklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1146    Accepted Submission(s): 491 Problem Description Little Q wants to buy a necklace for his girlfriend. Necklaces are single…