HDU 1452 (约数和+乘法逆元)】的更多相关文章

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1452 题目大意:求2004^X所有约数和,结果mod 29. 解题思路: ①整数唯一分解定理: 一个整数A一定能被分成:A=(P1^K1)*(P2^K2)*(P3^K3).....*(Pn^Kn)的形式.其中Pn为素数. 如2004=(22)*3*167. 那么2004x=(22x)*(3x)*(167x). ②约数和公式 对于一个已经被分解的整数A=(P1^K1)*(P2^K2)*(P3^K3)…
Problem Description Considera positive integer X,and let S be the sum of all positive integer divisors of2004^X. Your job is to determine S modulo 29 (the rest of the division of S by29). Take X = 1 for an example. The positive integer divisors of 20…
Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an example. The positive integer divisors of 2004^1 are 1, 2, 3,…
原题: http://acm.hdu.edu.cn/showproblem.php?pid=5651 很容易看出来的是,如果一个字符串中,多于一个字母出现奇数次,则该字符串无法形成回文串,因为不能删减字母. 当能构成回文串时,我们只需考虑这个回文串左半部分的情况,所以这个问题也就变成了求一半字符串的有重复的全排列. 因为应用全排列公式中,会用大数除以大数再取余,除法不能简单的分子.分母取余再做除法,这时就要用到乘法逆元,同时用费马小定理求乘法逆元 相关公式:http://www.cnblogs.…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1576 题目大意:求(A/B)mod 9973.但是给出的A是mod形式n,n=A%9973. 解题思路: 两种思路,一种从乘法逆元角度,另一种从扩展GCD推公式角度. ①乘法逆元: 先来看下逆元和乘法逆元的关系,对于A*X=B,有X=A-1*B,A-1就是普通的逆元了,在这里就是倒数. 如果A*X=B mod n,变成同余式了,那么A-1依然是存在的,只不过不是倒数了,一般把同余之后的逆元称为乘法…
Romantic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2835    Accepted Submission(s): 1117 Problem Description The Sky is Sprite.The Birds is Fly in the Sky.The Wind is Wonderful.Blew Throw t…
G - Happy 2004 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1452 Description Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to dete…
POJ1845:http://poj.org/problem?id=1845 思路: AB可以表示成多个质数的幂相乘的形式:AB=(a1n1)*(a2n2)* ...*(amnm) 根据算数基本定理可以得约数之和sum=(1+a1+a12+...+a1n1)*(1+a2+a22+...+a2n2)*...*(1+am+am2+...+amnm) mod 9901 对于每个(1+ai+ai2+...+aini) mod 9901=(ai(ni+1)-1)/(ai-1) mod 9901 (等比数列…
题目地址:pid=5407">HDU 5407 题意:CRB有n颗不同的糖果,如今他要吃掉k颗(0<=k<=n),问k取0~n的方案数的最小公倍数是多少. 思路:首先做这道题我们须要必备的几个技能点. 1. LCM(C(n,0), C(n,1),-, C(n,n))=LCM(1,2,3,-n+1)/(n+1).额,这个有一篇证明Kummer定理 2.(1) 乘法逆元定义: 满足a*k≡1 (mod p)的k值就是a关于p的乘法逆元(a,p互质). (2)为什么要用乘法逆元: 当…
题目: 求AB的正约数之和. 输入: A,B(0<=A,B<=5*107) 输出: 一个整数,AB的正约数之和 mod 9901. 思路: 根据正整数唯一分解定理,若一个正整数表示为:A=p1^c1 * p2^c2 * ...... pm^cm 则其正约数之和可以表示为:S=(1+p1+p1^2+......p1^c1)*(1+p2+p2^2+......p2^c2)*......(1+pm+pm^2+......pm^cm) 那么AB就可以表示为:S'=(1+p1+p1^2+......p1…