51nod 1046 A^B Mod C
2016-09-09 20:29
183 查看
快速幂
a^b %c = ( a%c * b%c)%c
a^b %c = ( a%c * b%c)%c
#include <iostream> #include <stdio.h> using namespace std; long long sum=0; void quicksort(int a,int b,int c) { long long z=a; long long ans=1; while(b!=0) { if(b&1) ans*=z; z=z*z; z%=c; ans%=c; b>>=1; } cout<<ans<<endl; } int main() { int a,b,c; cin>>a>>b>>c; quicksort(a,b,c); return 0; }
相关文章推荐
- 51nod 1046 A^BMod C
- 【51NOD-0】1046 A^B Mod C
- 51nod 1046 A^B Mod C
- 51nod_1046 A^B Mod C
- 51nod 1046 A^B Mod C
- 51nod 1046 A^B Mod C
- 51Nod 1046 A^B Mod C
- 51nod 1046 A^B Mod C(快速幂运算)
- 51Nod-1046 A^B Mod C(快速幂取模)
- 51nod 1046 A^B Mod C
- 51Nod-1046 A^B Mod C【快速模幂】
- 51Nod-1046-A^B Mod C
- 51Nod-1046 A^B Mod C 快速幂取模
- 51NOD 1046
- 1046 A^B Mod C
- 51NOD 1046
- 51 nod 1046 A^B Mod C
- 51Nod 1046 A^B Mod C(日常复习快速幂)
- 51nod 1046 A^B Mod C (快速幂)
- 【51nod】1046 A^B Mod C - 快速幂