The topic asks all factors of $a^b$ and.
The factorization of a according to the unique decomposition theorem can be made by: a = P1^A1 * P2^A2 * p3^a3 * pn^an.
a^b=p1^ (a1*b) *p2^ (a2*b) *...*pn^ (an*b);
All A^b and sum=[1+p1+p1^2+...+p1^ (a1*b)]*[1+p2+p2^2+...+p2^ (a2*b)]*[1+pn+pn^2+...+pn^ (an*b)]
Knowing this, the problem becomes to find all factorization pi and number N of a, and then $\prod (1+p_i+p_i^2+\cdots+p_i^{n-1}+p_i^n) $ on the line. You can construct a matrix to ask for:
Kee $s_n=p_i+p_i^2+\cdots+p_i^{n-1}+p_i^n$
$$ \begin{bmatrix} p_i & 1 \ 0 & 1 \end{bmatrix} \times \begin{bmatrix} s_n \ p_i \end{bmatrix} = \begin{bmatrix } s_{n+1} \ \ p_i \end{bmatrix} $$
$$ \begin{bmatrix} s_n \ p_i \end{bmatrix} = \begin{bmatrix} p_i & 1 \ 0 & 1 \end{bmatrix} ^n \times \begin{bmat RIX} s_0 \ P_i \end{bmatrix} $$
A forgot $\pmod {9901}$, burst intwa to headache = =
1#include <cstdio>2#include <cstring>3 using namespacestd;4 structmat{5 intm[2][2];6 };7Matoperator*(ConstMat &M1,ConstMat &m2) {8Mat m={0};9 for(intI=0; i<2; ++i) {Ten for(intj=0; j<2; ++j) { One for(intk=0; k<2; ++k) { Am.m[i][j]+=m1.m[i][k]*M2.m[k][j]; -m.m[i][j]%=9901; - } the } - } - returnm; - } + intCalU (intAintN) { -a%=9901; +Mat e={1,0,0,1},x={a,1,0,1}; A while(n) { at if(n&1) e=e*x; -x=x*x; -n>>=1; - } - return(e.m[0][1]*a+1)%9901; - } in BOOLIsPrime (intN) { - if(n<2)return 0; to for(intI=2; i*i<=n; ++i) { + if(n%i==0)return 0; - } the return 1; * } $ intMain () {Panax Notoginseng intb; -scanf"%d%d",&a,&b); the if(IsPrime (a)) { +printf"%d", CalU (A, b)); A return 0; the } + intres=1; - for(intI=2; i*i<=a; ++i) { $ if(a%i)Continue; $ if(IsPrime (i)) { - intCnt=0, tmp=A; - while(tmp%i==0){ the++CNT; -Tmp/=i;Wuyi } theRes*=calu (i,cnt*b); -res%=9901; Wu } - if(i!=a/i && IsPrime (A/i)) { About intCnt=0, tmp=A; $ while(tmp%i==0){ -++CNT; -Tmp/=i; - } ARes*=calu (a/i,cnt*b); +res%=9901; the } - } $printf"%d", res); the return 0; the}
POJ1845 Sumdiv (for all factors and + matrix fast Power)