题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=9213913904156AnanagramsAcceptedC++0.0092014-07-20 ...
分类:
其他好文 时间:
2014-07-22 08:07:37
阅读次数:
225
The DecoderWrite a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a si...
分类:
其他好文 时间:
2014-07-22 00:38:34
阅读次数:
235
Kindergarten Counting GameEverybody sit down in a circle. Ok. Listen to me carefully.``Woooooo, you scwewy wabbit!''Now, could someone tell me how man...
分类:
其他好文 时间:
2014-07-22 00:37:36
阅读次数:
248
UVA 10870 - Recurrences
题目链接
题意:f(n) = a1 f(n - 1) + a2 f(n - 2) + a3 f(n - 3) + ... + ad f(n - d), for n > d.
已知前d项求第n项
思路:矩阵快速幂,对应矩阵为
|a1 a2 a3 ... ad|
|1 0 0 ... 0 0 0|
|0 1 0 ... 0 0 ...
分类:
其他好文 时间:
2014-07-21 09:30:29
阅读次数:
211
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=17561391360710815Andy's First DictionaryAcceptedC+...
分类:
其他好文 时间:
2014-07-21 08:26:16
阅读次数:
243
UVA 10655 - Contemplation! Algebra
题目链接
题意:给定p, q, n代表p=a+b,q=ab求an+bn
思路:矩阵快速幂,公式变换一下得到(an+bn)(a+b)=an+1+bn+1+ab(an?1+bn?1),移项一下得到an+1+bn+1=(an+bn)p?q(an?1+bn?1)
这样就可以用矩阵快速幂求解了
代码:
...
分类:
其他好文 时间:
2014-07-20 23:36:03
阅读次数:
300
UVA 1386 - Cellular Automaton
题目链接
题意:给定一个n格的环,现在有个距离d,每次变化把环和他周围距离d以内的格子相加,结果mod m,问经过k次变换之后,环上的各个数字
思路:矩阵很好想,每个位置对应周围几个位置为1,其余位置为0,但是这个矩阵有500,有点大,直接n^3去求矩阵不太合适,然后观察发现这个矩阵是个循环矩阵,循环矩阵相乘的话,只需要...
分类:
其他好文 时间:
2014-07-20 23:16:53
阅读次数:
247
UVA 11149 - Power of Matrix
题目链接
题意:给定一个n*n的矩阵A和k,求∑kiAi
思路:利用倍增去搞,∑kiAi=(1+Ak/2)∑k/2iAi,不断二分即可
代码:
#include
#include
const int N = 45;
int n, k;
struct mat {
int v[N][N];
mat() ...
分类:
其他好文 时间:
2014-07-20 23:07:20
阅读次数:
274
Description
The army of United Nations launched a new wave of air strikes on terroristforces. The objective of the mission is to reduce enemy's logistical mobility. Each airstrike will destroy a pa...
分类:
其他好文 时间:
2014-07-20 23:04:26
阅读次数:
332
Square City is a very easy place for people to walk around. The two-way streets run North-South or East-West dividing the city into regular blocks. Most street int...
分类:
其他好文 时间:
2014-07-20 22:33:53
阅读次数:
295