大家好,又见面了,我是全栈君。
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13959 | Accepted: 3433 |
Description
Input
Output
Sample Input
2 3
Sample Output
15
Hint
The natural divisors of 8 are: 1,2,4,8. Their sum is 15.
15 modulo 9901 is 15 (that should be output).
Source
思路看:
http://hi.baidu.com/necsinmyway/item/9f10b6d96c5068fbb2f77740
AC代码:
#include<iostream>using namespace std;#define LL long longLL pow_mod(LL a,LL n,int mod){ //高速幂 LL r=1; LL base=a; while(n){ if(n&1) r=r*base%mod; base=base*base%mod; n>>=1; } return r%9901;}LL sum(LL a,LL b,LL mod){ //二分求等比数列前N项和 if(b==0) return 1; if(b%2==1) return (sum(a,b/2,mod)*(pow_mod(a,b/2+1,mod)+1))%mod; else return (sum(a,b-1,mod)+pow_mod(a,b,mod))%mod;}int main(){ LL a,b; LL ans; while(cin>>a>>b){ ans=1; for(LL i=2;i*i<=a;i++){ //将a分解为质数的乘积 if(a%i==0){ LL s=0; while(a%i==0){ s++; a/=i; } ans=ans*sum(i%9901,b*s,9901)%9901; } } if(a>=2){ ans=ans*sum(a%9901,b,9901)%9901; } cout<<ans<<endl; } return 0;}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/115395.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...