Cod sursa(job #1456803)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 1 iulie 2015 22:31:27
Problema Suma divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.83 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;
}

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++;
			}
			//cout<<p[i]<<" x "<<k<<"\n";
			s=(1LL*s*(binexp(p[i], b*k+1)-1))%MOD;
			s=(1LL*s*binexp(p[i]-1, MOD-2))%MOD;
		}
	}
	if(a>1)
	{
		s=(1LL*s*(binexp(a, b+1)-1))%MOD;
		s=(1LL*s*binexp(a-1, MOD-2))%MOD;
	}
	cout<<s;
	
	return 0;
}