Cod sursa(job #1456893)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 2 iulie 2015 13:02:58
Problema Suma divizorilor Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.85 kb
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define FILL(x,y) memset(x,y,sizeof(x))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define x first
#define y second
#define st first
#define nd second
#define pb push_back
#define l(n) (n<<1)
#define r(n) ((n<<1)+1)
#define f(n) (n>>1)
#define lsb(a) (a&-a)

#include<vector>

using namespace std;
#include<fstream>
ifstream cin("sumdiv.in");
ofstream cout("sumdiv.out");

const int CIUR = 10000;
const int MOD = 9901;
const int INF = 0x3f3f3f3f;
const int dx[] = {0,0,-1,1}; //1,1,-1,1};
const int dy[] = {-1,1,0,0}; //1,-1,1,-1};

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef pair<K, K> PKK;
typedef vector<int> VI;

int n,m,i,j;
bool viz[CIUR];
long long p[CIUR];

void ciur()
{
	int k=0;
	for(int i=2; i<=CIUR; ++i)
		if(!viz[i])
		{
			p[++k]=i;
			for(int j=2*i; j<=CIUR; j+=i)
				viz[j]=true;
		}
}

long long binexp(long long n, long long p)
{
	long long x=1;
	while(p)
	{
		if(p&1)
		{
			x=(1LL*x*n)%MOD; p--;
		}
		n=(1LL*n*n)%MOD;
		p/=2;
	}
	return x%MOD;
}

int calc(int p, long long a)
{
	if(p==1)
		return (a+1)%MOD;
	return 1LL*(binexp(p, a+1)+MOD-1)*binexp(p ? p - 1 : 9900, MOD-2);
}

long long a,b,s;

int main()
{
	cin>>a>>b;
	ciur();
	s=1;
	for(int i=1; 1LL*p[i]*p[i]<=a; ++i)
	{
		if(a%p[i]==0)
		{
			long long k=0;
			
			while(a%p[i]==0)
			{
				a/=p[i];
				k++;
			}
			s=(1LL*s*calc(p[i]%MOD, b*k))%MOD;
		}
	}
	if(a>1)
	{
		s=(1LL*s*calc(a%MOD, b))%MOD;
	}
	cout<<s;
	
	return 0;
}