题目链接:uva 10743 - Blocks on Blocks
题目大意:问说n联骨牌有多少种,旋转镜像后相同不算同一组,一行的格子必须连续,如果答案大于10000,输出后四位。
解题思路:想了一下午的递推式,实在受不了,把推出的序列在网上搜了一下,有公式ai=5?ai?1?7?ai?2+4?ai?3
(i≥5)
PS:哪位神人知道怎么推出来的请留言我,大恩不言谢~
#...
分类:
其他好文 时间:
2014-08-02 12:57:43
阅读次数:
227
题目:uva10453 - Make Palindrome(递推+ 路径输出)
题目大意:给出一字符串,仅仅只能做增加字符的操作,问最少增加多少字符串可以是的最后的字符串变成回文。并且将这样的字符串(增加长度要是最小的)的任意一种输出。
解题思路:dp【i】【j】代表第i个字符到第j个字符之间要增加的最少的字符串。递推公式:s【i】 == s【j】, dp【i】【j】 = dp...
分类:
其他好文 时间:
2014-08-02 12:56:43
阅读次数:
275
题目大意:
给出一个递推的关系。
这个递推的关系可以求出 s_1 s_2 s_3 .... s_m
然后再告诉一个 k 与 n
求出segma( s_k , s_2*k , s_3*k)...共n项。
思路分析:
首先给出来的是递推关系式。
所以可以用一个矩阵递推出 s [i]...
但是他要的是每隔k的值。
定义s的递推矩阵是 A
SUM = S_k + S_2*...
分类:
其他好文 时间:
2014-08-02 12:49:03
阅读次数:
219
哎,最近都在做图论,没有练DP,现在一遇到DP就不会了= =因为有合并这个操作,所以只要是首位相同的字符串肯定是能够构成good串的,那么只要统计在奇数位上出现的0,1的个数和偶数位数,随便递推一下就出来了#include #include #include #include #include #i...
分类:
其他好文 时间:
2014-07-31 23:34:50
阅读次数:
241
一般用来加速递推。
简单的,对于fib数列有,f0 = 1,f1 = 1,fn = fn-1 + fn-2(n >= 2)。
则对于fn有:
一般的,对于fn = A1*f(n-1) + A2*f(n-2) + .... +A(n-1)*f1,有:
又因为矩阵乘法满足结合律,所以可以用快速幂来求A^n,从而达到递推的效果。
顺便即一个小技巧:
...
分类:
其他好文 时间:
2014-07-31 20:51:27
阅读次数:
227
如果求出第一种情况的逆序列,其他的可以通过递推来搞出来,一开始是t[1],t[2],t[3]....t[N]它的逆序列个数是sum个,如果把t[1]放到t[N]后面,逆序列个数会减少t[1]个,相应会增加N-(t[1]+1)个 1 #include 2 #include 3 using name.....
分类:
其他好文 时间:
2014-07-31 20:21:17
阅读次数:
270
Description
Your rich uncle died recently, and the heritage needs to be divided among your relatives and the church (your uncle insisted in his will that the church must get something). There are...
分类:
其他好文 时间:
2014-07-31 17:15:36
阅读次数:
223
Description
Recall the definition of the Fibonacci numbers:
f1 := 1
f2 := 2
fn := fn-1 + fn-2 (n>=3)
Given two numbers a and b, calculate how many Fibonacci numbers are in the range...
分类:
其他好文 时间:
2014-07-31 17:11:07
阅读次数:
325
Description
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many ...
分类:
其他好文 时间:
2014-07-31 17:08:06
阅读次数:
267