Cod sursa(job #1996463)
| Utilizator | Data | 1 iulie 2017 16:55:33 | |
|---|---|---|---|
| Problema | Suma divizorilor | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include<cstdio>
using namespace std;
const int mod=9901;
int a,b;
inline int power(int k)
{
if(k==0)
return 1;
if(k&1)
return a*power(k-1);
int temp=power(k/2)%mod;
return (temp*temp)%mod;
}
inline int sum(int k)
{
if(k==0)
return 1;
if(k&1)
return (1+a*sum(k-1))%mod;
int temp=sum(k>>1)%mod;
return (temp+power(k>>1)*(temp-1))%mod;
}
int main()
{
freopen("sumdiv.in","r",stdin);
freopen("sumdiv.out","w",stdout);
scanf("%d%d",&a,&b);
printf("%d",sum(b));
}
