BZOJ1965 [Ahoi2005]SHUFFLE 洗牌 2018-10-10 题解 BZOJ 评论 字数统计: 111(words) 题面在这里 \[ x\cdot 2^m\equiv L\pmod {n+1} \\ x\equiv L\cdot \left( \frac {n+2} 2 \right)^m \pmod {n+1} \] 示例程序: 123456789101112131415161718#include<cstdio>typedef long long ll;ll n,m,l,MOD;ll power(ll a,ll b){ ll w=a%MOD,res=1; while (b){ if (b&1) (res*=w)%=MOD; (w*=w)%=MOD; b>>=1; } return res;}int main(){ scanf("%lld%lld%lld",&n,&m,&l);MOD=n+1; printf("%lld",l*power(n/2+1,m)%MOD); return 0;}