为什么10分?快速幂qaq。。。急

P3197 [HNOI2008] 越狱

.....直接上没问题么
by 卜卜 @ 2017-02-12 08:19:24


先把基础的快速幂打好再去玩位运算,不然可能出了错自己都查不出来。
by Sor4 @ 2017-02-12 14:49:20


你这个地方显然是会爆出负数的,至于为什么或者怎么解决你可以继续去思考
by Sor4 @ 2017-02-12 14:50:50


比较基础的快速幂: ```cpp int64 pow_mod(int64 x,int64 n,int64 mod){ int64 res=1; while (n>0){ if (n%2==1) res=res*x%mod; x=x*x%mod; n/2; } return res; } ```
by Alextokc @ 2017-02-13 12:01:35


@[Alextokc](/space/show?uid=26050) 再比较基础的快速幂(可能有bug) ```cpp int pow(int a,int n){ if (n==0) return 1; if (n==1) return a; if (n%2==0) return pow(a,n/2)*pow(a,n/2); return pow(a,n/2)*pow(a,n/2)*a; } ```
by Flokirie @ 2017-10-24 13:25:54


@[Alextokc](/space/show?uid=26050) 你那n/2是什么鬼
by Salamander @ 2017-10-24 14:35:01


@[Salamander](/space/show?uid=20176) 他可能是想写n/=2……
by Flokirie @ 2017-10-24 15:03:19


@[Flokirie](/space/show?uid=51001) ...=\_=||
by Salamander @ 2017-10-24 15:32:04


|