HDU 1420 Prepared for New Acmer
2013-07-01 10:16
435 查看
蒙哥马利算法 0ms
暴力法 109ms
#include<iostream> using namespace std; int main() { int m; __int64 a,b,c; cin>>m; while(m--) { cin>>a>>b>>c; a%=c; __int64 t=1; while(b) { if(b&1) t=t*a%c; b=b>>1; a=(a*a)%c; } cout<<t<<endl; } return 0; }
暴力法 109ms
#include<iostream> using namespace std; int main() { int m,i; __int64 a,b,c; cin>>m; while(m--) { cin>>a>>b>>c; a%=c; __int64 t=a; for(i=2;i<=b;i++) { t=(t*a)%c; if(t==0) break; } cout<<t<<endl; } return 0; }
相关文章推荐
- HDU 1420 Prepared for New Acmer
- hdu 1420 Prepared for New Acmer
- hdu 1420(Prepared for New Acmer)(中国剩余定理)(降幂法)
- HDU 1420 Prepared for New Acmer(快速幂)
- hdu-1420-Prepared for New Acmer-递归-java
- HDU 1420 Prepared for New Acmer(数学题)
- hdu1420 Prepared for New Acmer ——快速幂
- 【HDU】1420 Prepared for New Acmer(水题、取余)
- hdu_1420 Prepared for New Acmer
- hdu 1420(Prepared for New Acmer)(中国剩余定理)(降幂法)
- hdu1420 Prepared for New Acmer 简单数学
- HDU 1420--Prepared for New Acmer【快速幂取模】
- hdu1420 Prepared for New Acmer (a^i mod n)
- hdu 1420 Prepared for New Acmer(矩阵快速幂模板)
- HDU 1420 Prepared for New Acmer【快速幂】
- hdu 1420 Prepared for New Acmer(快速幂入门)
- hdu 1420 Prepared for New Acmer
- HDU 1420 Prepared for New Acmer(快速幂取模)
- HDU 1420 Prepared for New Acmer
- HDU 1420 Prepared for New Acmer(快速幂裸题)