hdu-2865-polya+dp+矩阵+euler函数】的更多相关文章

Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 644    Accepted Submission(s): 326 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 866    Accepted Submission(s): 456 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
这题模数是9937还不是素数,求逆元还得手动求. 项链翻转一样的算一种相当于就是一种类型的置换,那么在n长度内,对于每个i其循环节数为(i,n),但是由于n<=2^32,肯定不能直接枚举,所有考虑枚举gcd,对应的n/gcd就是其个数,有点容斥的思想.全部累加最后除以n就计算好染色方案了. 注意这题很卡时间,而且很玄的用long long会错,要先求出上界再枚举,循环中i*i的循环条件会很慢. /** @Date : 2017-09-18 23:33:30 * @FileName: HDU 22…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5434 Peace small elephant  Accepts: 38  Submissions: 108  Time Limit: 10000/5000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 小明很喜欢国际象棋,尤其喜欢国际象棋里面的大象(只要无阻挡能够斜着走任意格),但是他觉得国际象棋里的大象太凶残了…
该题非常easy想到求概率的转移方程:用d[i][j]表示第i步,走到j点的概率. 可是该题的k高达1e9.所以依照套路.要用矩阵相乘来优化. 第一次写矩阵相乘. 大概的意思就是利用矩阵实现递推. 而且由于每次递推的过程一样, 所以就相当于右乘这个矩阵的k次方. 用矩阵高速幂就可以. 矩阵相乘这个问题, 大概能够看成, 矩阵中的每一个元素表示到该点的概率, 那么还有一个矩阵就是DP矩阵, 表示当前一步到各点的概率. 矩阵相乘就等于下一步到各点的概率(矩阵乘法的意义). 另外. 要对答案进行1e9…
Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 218    Accepted Submission(s): 106 Problem Description You may not know this but it's a fact that Xinghai Square is…
题目链接: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=4123 Problem Description Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in his village. Each road connects two houses,…
http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以.他生平最恨情人节,无论是214还是77.他都讨厌! 吉哥观察了214和77这两个数,发现: 2+1+4=7 7+7=7*2 77=7*11 终于,他发现原来这一切归根究竟都是由于和7有关!所以,他如今甚至讨厌一切和7有关的数. 什么样的数和7有关呢? 假设一个整数符合以下3个条件之中的一个.那么我…
http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit.…