POJ 1845-Sumdiv(厉害了这个题)】的更多相关文章

筛选法+求一个整数的分解+快速模幂运算+递归求计算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…
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…
任意门: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…
题目链接:http://poj.org/problem?id=1845 题目大意:给出两个自然数a,b,求a^b的所有自然数因子的和模上9901 (0 <= a,b <= 50000000) 解题思路:我们先利用唯一分解定理,将a分解成(p1^q1)*(p2^q2)……(pk^qk)的形式,则a^b=((p1^q1)*(p2^q2)……(pk^qk))^b=(p1^q1b)*(p2^q2b)……(pk^qkb) a^b的因子和就会等于(1+p1+p1^2+……p1^q1b)*(1+p2+p2^…
题目链接: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…
传送门: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: 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…
题目链接: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+..…
题目链接 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…
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 natural numbers A and B, (0 <= A,B <= 50000000)s…