链接:http://acm.hdu.edu.cn/showproblem.php?pid=5318 The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 438    Accepted Submission(s): 150 Problem Description Chang'e (嫦娥) is…
题目:pid=5318">http://acm.hdu.edu.cn/showproblem.php?pid=5318 题意:给定n个数字串和整数m,规定若数字串s1的后缀和数字串s2的前缀同样且长度≥2,则s2能够拼接在s1的后面,每一个串能够反复用,问拼接m个数字串有多少种方法. n<=50,m<=1e9 分析:定义dp[i][j]为拼接了i个串而且这个长串以s[j](输入的第j个数字串)结尾的方案数. 那么有 for(int i=1;i<=n;i++) dp[1][…
Another kind of Fibonacci                                                        Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)                                                                                   Tot…
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 589    Accepted Submission(s): 251 Problem Description Chang’e (嫦娥) is a well-known character in Chinese ancient mythology…
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 943    Accepted Submission(s): 426 Problem Description Chang’e (嫦娥) is a well-known character in Chinese ancient mythology…
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1487    Accepted Submission(s): 650 Problem Description Chang’e (嫦娥) is a well-known character in Chinese ancient mytholog…
题目地址:HDU 1757 最终会构造矩阵了.事实上也不难,仅仅怪自己笨..= =! f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10) 构造的矩阵是:(我代码中构造的矩阵跟这个正好是上下颠倒过来了) |0 1 0 ......... 0|    |f0|   |f1 | |0 0 1 0 ...... 0|    |f1|   |f2 | |...................1| *  |..| = |...…
和这一题构造的矩阵的方法同样. 须要注意的是.题目中a0~a9 与矩阵相乘的顺序. #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #define N 10 using namespace std; int mod; typedef long long LL; struct matrix { LL a[10…
http://acm.hdu.edu.cn/showproblem.php?pid=3221 一晚上搞出来这么一道题..Mark. 给出这么一个程序.问funny函数调用了多少次. 我们定义数组为所求:f[1] = a,f[2] = b, f[3] = f[2]*f[3]......f[n] = f[n-1]*f[n-2].相应的值表示也可为a^1*b^0%p.a^0*b^1%p,a^1*b^1%p,.....a^fib[n-3]*b^fib[n-2]%p.即a,b的指数从n=3以后与fib数列…
题目地址:HDU 1575 矩阵高速幂裸题. 初学矩阵高速幂.曾经学过高速幂.今天一看矩阵高速幂,原来其原理是一样的,这就好办多了.都是利用二分的思想不断的乘.仅仅只是把数字变成了矩阵而已. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #i…