当我们拆分完数据以后, A^B的所有约数之和为: sum = [1+p1+p1^2+...+p1^(a1*B)] * [1+p2+p2^2+...+p2^(a2*B)] *...*[1+pn+pn^2+...+pn^(an*B)]. 当时面对等比数列的时候,想到了求和公式,因为直接算超时了,但是带膜除法不能直接除,所以又想到了乘法逆元,但是逆元的使用条件是除数和mod互质的时候,题目给我们的膜不够大,然后我就方了,不知道该怎么去处理了,后来看到网上,才学会了等比快速求和的方法. 它的思想是二分法…
筛选法+求一个整数的分解+快速模幂运算+递归求计算1+p+p^2+````+p^nPOJ 1845 Sumdiv求A^B的所有约数之和%9901 */#include<stdio.h>#include<math.h>#include<iostream>#include<algorithm>#include<string.h>using namespace std;#define MOD 9901const int MAXN=10000;int p…
传送门:http://poj.org/problem?id=1845 大致题意: 求A^B的所有约数(即因子)之和,并对其取模 9901再输出. 解题基础: 1) 整数的唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式. ,其中为素数 2) 约数和公式: 对于已经分解的整数,A的所有因子之和为 3) 同余模公式: (a+b)%m=(a%m+b%m)%m (a*b)%m=(a%m*b%m)%m 1: 对A进行素因子分解 这里如果先进行筛50000内的素数会爆空间,只能用最朴素的…
题目链接 Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 25841   Accepted: 6382 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S…
题意:给你A,B,让求A^B所有的因子和模上9901 思路:A可以拆成素因子的乘积: A = p1^x1 * p2^x2 *...* pn^xn 那么A^B = p1^(B*x1) * p2^(B*x2) *...* pn^(B*xn) 那么A^B所有的素因子和就是 (p1^0 + p1^1 + p1^2 + ... + p1^(B*x1) ) * (p2^0 + p2^1 + ... + p2^(B*x2) ) * ... * (pn^0 + pn^1 + ... + pn^(B*xn)) 可…
Sumdiv 题目连接: http://poj.org/problem?id=1845 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901). Input The only line contains the two natur…
题目链接:Sumdiv 题意:给定两个自然数A,B,定义S为A^B所有的自然因子的和,求出S mod 9901的值. 题解:了解下以下知识点   1.整数的唯一分解定理 任意正整数都有且只有唯一的方式写出其质因子的乘积表达式 $A={p_1}^{k_1}*{p_2}^{k_2}*{p_3}^{k_3}*...*{p_n}^{k_n}$ 2.整数因数个数 $B=(k_1+1)*(k_2+1)*(k_3+1)...*(k_n+1)$ 3.整数因数总和 $S=(1+p_1+p_1^2+p_1^3+..…
任意门:http://poj.org/problem?id=1845. Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 30268 Accepted: 7447 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the…
快速幂+等比数列求和.... Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 12599 Accepted: 3057 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division…
题目链接:http://poj.org/problem?id=1845 关于质因数分解,模板见:http://www.cnblogs.com/atmacmer/p/5285810.html 二分法思想:选定一个要进行比较的目标,在区间[l,r]之间不断二分,直到取到与目标相等的值. #include<iostream> #include<cstdio> #include<cstring> using namespace std; typedef long long ll…