Demo entry 6770672

py

   

Submitted by 反对法 on Nov 14, 2018 at 10:17
Language: C++. Code size: 232 Bytes.

#define LL long long 
// 快速幂 计算 x^a % P 
LL Power_Mod(LL x,LL a,LL P)
    LL res=1;// 答案值
    for(;a;a>>=1,x=x*x%P){//找a的第i位时,x=[x^(2^(i-1))]^2=x^(2^i)
    	if(a&1)res=res*x%P;// 如a的第i位为1,答案值乘上x^(2^i)
    }
    return res;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).