快速幂模板

来源:互联网 发布:免费网页游戏源码 编辑:程序博客网 时间:2024/06/10 02:11
#include<stdio.h>#include<stdlib.h>#include<iostream>#include<string.h>#include<cstring>#include<string>#include<math.h>#include<algorithm>#include<set>#include<vector>#define LL long long#define INF 0x3f3f3f3f#define mod 1e9+7using namespace std;LL solve(int e, int x){    LL ans = 1;    while(x){        if(x & 1) ans *= e;///这里只有奇数才会进行运算额        e *= e;        x = x >> 1;    }    return ans;}int main(){    printf("%lld\n",solve(2,5));    return 0;}

0 0
原创粉丝点击