# RXD and math

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1363    Accepted Submission(s): 747

Problem Description
RXD is a good mathematician.
One day he wants to calculate:
i=1nkμ2(i)×nki

1n,k1018
μ(n)=1(n=1)

μ(n)=(1)k(n=p1p2pk)

μ(n)=0(otherwise)

p1,p2,p3pk are different prime numbers

Input
There are exact 10000 cases.
For each test case, there are 2 numbers n,k.

Output
For each test case, output "Case #x: y", which means the test case number and the answer.

Sample Input
10 10

Sample Output
Case #1: 999999937

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#define ll long long
#define mset(a,x) memset(a,x,sizeof(a))

using namespace std;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e5+5;
const int mod=1e9+7;
int dir[4][2]={0,1,1,0,0,-1,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

int main()
{
ll n,k,i,j,flag=1;
while(~scanf("%lld%lld",&n,&k))
{
n=n%mod;
ll ans=fpow(n,k);
cout<<"Case #"<<flag++<<": "<<ans<<endl;
}
return 0;
}

• 评论

• 上一篇
• 下一篇