CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 483 Accepted Submission(s): 198 Problem Description CRB is now playing Jigsaw Puzzle. There are kinds of pieces with infinite…
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5062 Accepted: 1370 Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties, YYF is now…
链接 题解链接:http://www.cygmasot.com/index.php/2015/08/20/hdu_5411/ 给定n个点 常数m 以下n行第i行第一个数字表示i点的出边数.后面给出这些出边. 问:图里存在多少条路径使得路径长度<=m.路径上的点能够反复. 思路: 首先能得到一个m*n*n的dp.dp[i][j]表示路径长度为i 路径的结尾为j的路径个数 . 答案就是sigma(dp[i][j]) for every i from 1 to m, j from 1 to n; 我们…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985 We define a kind of strings as elegant string: among all the substrings of an elegant string, none of them is a permutation of "0, 1,…, k". Let function(n, k) be the number of elegant s…
UVA 11551 - Experienced Endeavour 题目链接 题意:给定一列数,每一个数相应一个变换.变换为原先数列一些位置相加起来的和,问r次变换后的序列是多少 思路:矩阵高速幂,要加的位置值为1.其余位置为0构造出矩阵,进行高速幂就可以 代码: #include <cstdio> #include <cstring> const int N = 55; int t, n, r, a[N]; struct mat { int v[N][N]; mat() {mem…
Cellular Automaton Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 3048 Accepted: 1227 Case Time Limit: 2000MS Description A cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of dis…
矩阵高速幂: 依据关系够建矩阵 , 高速幂解决. Arc of Dream Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2164 Accepted Submission(s): 680 Problem Description An Arc of Dream is a curve defined by following fun…
MF( i ) = a ^ fib( i-1 ) * b ^ fib ( i ) ( i>=3) mod 1000000007 是质数 , 依据费马小定理 a^phi( p ) = 1 ( mod p ) 这里 p 为质数 且 a 比 p小 所以 a^( p - 1 ) = 1 ( mod p ) 所以对非常大的指数能够化简 a ^ k % p == a ^ ( k %(p-1) ) % p 用矩阵高速幂求fib数后代入就可以 M斐波那契数列 Time Limit: 3000/100…
题目连接:uva 11885 - Number of Battlefields 题目大意:给出周长p,问多少种形状的周长为p的,而且该图形的最小包围矩阵的周长也是p,不包含矩形. 解题思路:矩阵高速幂.假设包括矩形的话,相应的则是斐波那契数列的偶数项,所以相应减去矩形的个数就可以. #include <cstdio> #include <cstring> using namespace std; typedef long long ll; const ll MOD = 987654…
How many ways? ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2046 Accepted Submission(s): 758 Problem Description 春天到了, HDU校园里开满了花, 姹紫嫣红, 很漂亮. 葱头是个爱花的人, 看着校花校草竞相开放, 漫步校园, 心情也变得舒畅. 为了多看看这…