http://codeforces.com/gym/101161/attachments 这题通过打表,可以知道长度是i的时候的合法方案数. 然后得到f[1] = 2, f[2] = 3, f[3] = 5, f[4] = 8......这样的广义fib数列 现在要求f[k] + f[2k] + f[3k] + ...... + f[xk]的总和. 直接做很难做,我不知道f[i * k] = x * f[(i - 1) * k] + y * f[(i - 2) * k] 推不出系数的话,有一个结…
题目链接 题意 :  给定长度为n的数组a,定义一次操作为: 1. 算出长度为n的数组s,使得si= (a[1] + a[2] + ... + a[i]) mod 1,000,000,007: 2. 执行a = s: 现在问k次操作以后a长什么样. 分析 : 这种不断求前缀和的操作.可以考虑构造操作矩阵.最后矩阵快速幂求答案 设 dp[k][i] 为第 k 次操作.第 i 个数的值 则可以得到递推式 dp[k][1] = dp[k-1][1] dp[k][2] = dp[k-1][2] + dp…
H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output A sequence of positive and non-zero integers called palindromic if it can be read the same forward and backward, for exa…
题目链接 题意 : 中文题.点链接 分析 : 有道题是问你不断求前缀和后的结果 Click here 这道题问的是逆过程 分析方法雷同.可参考 Click here -------------------------------------------------------------------------------- 正着做的矩阵是一个下三角 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 结合杨辉三角可得 C(k, 0) C(k+1, 1)      C(k, 0) C…
题意:给出一个字符集和一个字符串和正整数n,问由给定字符集组成的所有长度为n的串中不以给定字符串为连续子串的有多少个? 析:n 实在是太大了,如果小的话,就可以用动态规划做了,所以只能用矩阵快速幂来做了,dp[i][j] 表示匹配完 i 到匹配 j 个有多少种方案,利用矩阵的性质,就可以快速求出长度为 n 的个数,对于匹配的转移,正好可以用KMP的失配函数来转移. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000")…
题目链接: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…
题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=6030 Problem Description 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,…
传送门:点我 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…
You are given n integers a1,  a2,  ...,  an. A sequence of integers x1,  x2,  ...,  xk is called a "xor-sequence" if for every 1  ≤  i  ≤  k - 1 the number of ones in the binary representation of the number xi  xi  +  1's is a multiple of 3 and …
772002画马尾 题目连接: http://acm.uestc.edu.cn/#/problem/show/1280 Description 众所周知772002很喜欢马尾,所以他决定画几幅马尾送给他的女朋友. 772002会画m种马尾,772002还有n张纸,n张纸分别编号1到n,每张纸上只能画一种马尾. 然而772002的女朋友只喜欢其中t种马尾.并且772002的女朋友只喜欢偶数(因为这象征着成对成双). 772002想知道有多少种画法,使得n张纸画满并且自己女朋友喜欢的那t种马尾每种个…