描述

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).

输入

The only line contains the two natural numbers A and B, (0 <= A,B <= 50000000)separated by blanks.

输出

The only line of the output will contain S modulo 9901.

样例输入

2 3

样例输出

15

提示

2^3 = 8.

The natural divisors of 8 are: 1,2,4,8. Their sum is 15.

15 modulo 9901 is 15 (that should be output).

大概意思是让我们求 \(a^b\) 的所有因数的和膜9901的值

我们知道在算数基本定理中有 : \(a=p_{1}^{c_{1}}*p_{2}^{c_{2}}........*p_{n}^{c_{n}}\)(第一次用LaTeX)

所以\(a^b\)的约数和为 \((1+p_{1}+p_{1}^{2}.......+p_{1}^{b*c_{1}})*(1+p_{2}+p_{2}^{2}.......+p_{2}^{b*c_{2}}).....*(1+p_{n}+p_{n}^{2}.......+p_{n}^{b*c_{n}})\)

对于上面的每一项我们用等比公式求和

\(1+p_{1}+p_{1}^{2}.......+p_{1}^{b*c_{1}}\) = \(p_{1}^{b*c_{1}+1}-1\)/\(p_{1}-1\)

#include <cstdio>
#include <vector>
typedef long long int ll;
const ll mod=9901;
std::vector<ll> prime;
std::vector<ll> times;
inline void divide(ll n) {
for(ll i=2;i*i<=n;++i) {
if(n%i==0) {
prime.push_back(i);ll cnt=0;
while(n%i==0) {n/=i;++cnt;}
times.push_back(cnt);
}
}
if(n>1) {prime.push_back(n);times.push_back(1);}
}
inline ll qpow(ll n,ll k) {
ll ans=1;
while(k) {
if(k&1) ans=ans*n%mod;
n=n*n%mod;k>>=1;
}
return ans;
}
int main() {
ll a,b;scanf("%lld%lld",&a,&b);
divide(a);
ll ans=1;
for(int i=0,end=prime.size();i<end;++i) {
times[i]*=b;
if((prime[i]-1)%mod==0) ans=ans*(times[i]+1)%mod;
else ans=ans*((qpow(prime[i],times[i]+1)-1+mod)*qpow(prime[i]-1,mod-2)%mod)%mod;
}
printf("%lld\n",ans);
return 0;
}

最新文章

  1. 动态设置 button的 name 的话 闪动的问题 解决
  2. PHP框架中最喜欢的WindFramework
  3. inner join、left join、right join等的区别
  4. fastjson解析任意json
  5. IntelliSense: 应输入声明的解决方案
  6. eclipse中 起动tomcat时报Multiple Contexts have a path of &quot;/shopping&quot;
  7. linux实例 批量修改图片文件名
  8. python 程序列表
  9. Go语言简介
  10. linux命令学习笔记
  11. Android自定义Activity酷炫的动画跳转效果
  12. zoj 1184
  13. JQuery Ajax实例总结
  14. shell中的readonly
  15. 在TextBox中敲击回车执行ASP.NET后台事件
  16. JFace dailog button事件中刷新透视图异常 Trying to execute the disabled command org.eclipse.ui.window.closePerspective
  17. WebGL three.js学习笔记 创建three.js代码的基本框架
  18. C语言ftell()函数
  19. [Swift]LeetCode700. 二叉搜索树中的搜索 | Search in a Binary Search Tree
  20. zepto 事件分析3(add函数)

热门文章

  1. AgileConfig 轻量级配置中心 1.5 发布 - 支持多环境配置
  2. Java:Object对象小记
  3. [对对子队]会议记录4.16(Scrum Meeting7)
  4. [no code][scrum meeting] Beta 6
  5. 北航OO第三单元总结
  6. Spring中自定义Schema扩展机制
  7. CSP-S 2021 爆零记
  8. Spring Cloud Alibaba环境搭建
  9. uni-app使用wx-canvas实现微信小程序上显示地图map和坐标geo
  10. oxidized备份华为HRP防火墙配置失败问题