`

fastPow( 比pow好用、灵活的)

阅读更多
#include <iostream>
 
using namespace std;
 
int main()
{
    int a,b;
    cin >> a >> b;
    int res = 1;
    while(b){
            cout << b;
        if(b&1) { //位运算 与 末尾为1
         cout << "df";
                res*=a;
        }
        a*=a; //a的2、4、8、16次方 所以比pow 的快
 
        b=b>>1;
    }
 
    cout << res;
    return 0;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics