POJ-1845 Sumdiv (基础数论综合)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const ll mod=9901;
ll p,bk[5005],sum[5005],q[5005];
void fj(ll x)
{
p=0;
memset(sum,0,sizeof(sum));
for(int i=2;i*i<=x+1;i++)
{
if(x%i==0)
{
q[++p]=i;
while(x%i==0)
sum[p]++,x/=i;
}
}
if(x>1)
q[++p]=x,sum[p]=1;
}
ll qpow(ll a,ll b)
{
ll ans=1;
ll base=a;
while(b)
{
if(b&1)
ans=ans%mod*base%mod,ans%=mod;
base=base%mod*base%mod,base%=mod;
b>>=1;
}
return ans%mod;
}
ll getsum(ll a,ll b)
{
if(b==0)
return 1;
if(b%2==1) //奇数式
return ((1+qpow(a,(b+1)/2))*getsum(a,(b-1)/2)%mod)%mod;
if(b%2==0) //偶数式
return ((1+qpow(a,b/2))*getsum(a,(b/2)-1)%mod+qpow(a,b))%mod;
}
int main()
{
ll n,m,ans=0;
while(~scanf("%lld%lld",&n,&m))
{
fj(n);
ans=1;
for(int i=1;i<=p;i++)
{
ans=ans%mod*(getsum(q[i],sum[i]*m))%mod;
ans%=mod;
}
printf("%lld\n",ans%mod);
}
}
就算是一分钱,也是对作者极大的支持
------ 本文结束 ------

版权声明

Baccano by baccano is licensed under a Creative Commons BY-NC-ND 4.0 International License.
baccano创作并维护的Baccano博客采用创作共用保留署名-非商业-禁止演绎4.0国际许可证
本文首发于baccano 博客( http://baccano.fun ),版权所有,侵权必究。

小游戏

---小游戏:要不要来选择一下自己可能的老婆?---

简易发声器

---简易的七键钢琴插件---

可以使用鼠标点击琴键也可以使用主键盘1-7或者小键盘的1-7来操作

那么现在开始吧

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
0%