Test instructions: Read the Chinese question for yourself.
Analysis: This problem is divided into two steps
The first step: using the known formula to find K;
The second step: Find K and then use Euler power formula can, Euler power formula does not need coprime (the second step is to BZOJ3884 the original problem)
If you ask for K, you need to construct it (introduce the official puzzle)
And then I'm going to find out K, and I wonder why it is, and then search the Internet.
Found a derivation (after reading the Epiphany)
Derivation Link: http://blog.csdn.net/wust_zzwh/article/details/51966450
High admiration for the great giant of mathematics
Spit Groove: This question n is a square-free factor, and then to the Euler function is the properties of the integrable function to think, but mainly to do more math problems
#include <stdio.h>#include<iostream>#include<algorithm>#include<string.h>#include<vector>#include<math.h>#include<stack>#include<map>using namespaceStd;typedefLong LongLL;Const intN = 1e7+5;Const intmod=1e9+7;BOOLCheck[n]; LL Phi[n],prime[n>>1],tot; LL sum[n],k,n,m,p; ll Qpow (ll a,ll b,ll MoD) {LL ret=1; while(b) {if(b&1) ret= (ret*a)%MoD; A= (a*a)%MoD; b>>=1; } returnret;}voidGetphi () {phi[1]=1; tot=0; for(intI=2; i<=n-5;++i) { if(!Check[i]) {prime[++tot]=i; Phi[i]=i-1; } for(intj=1; j<=tot;++j) { if(i*prime[j]>n-5) Break; Check[i*prime[j]]=true; if(i%prime[j]==0) {Phi[i*prime[j]]=phi[i]*Prime[j]; Break; } Elsephi[i*prime[j]]=phi[i]* (prime[j]-1); } } for(intI=1; i<=n-5;++i) {Sum[i]= (sum[i-1]+phi[i])%MoD; }}ll Solve (LL n,ll m) {if(m==0)return 0; if(m==1)returnPhi[n]; if(n==1)returnSum[m]; if(phi[n]==n-1){ return(Phi[n]*solve (1, m)%mod+solve (n,m/n))%MoD; } for(intI=1; i<=tot&&prime[i]*prime[i]<=n;++i) { if(N%prime[i])Continue; return(Phi[prime[i]]*solve (n/prime[i],m)%mod+solve (N,m/prime[i]))%MoD; }}ll f (LL x) {if(x==1)return 0; returnQpow (K,f (phi[x]) +phi[x],x);}intMain () {Getphi (); while(~SCANF ("%i64d%i64d%i64d",&n,&m,&p)) {k=solve (n,m); printf ("%i64d\n", F (p)); } return 0;}
View Code
Derivation of HDU 5278 powmod number theory formula