快速幂
来源:互联网 发布:考研形势数据图表分析 编辑:程序博客网 时间:2024/06/06 09:52
//快速幂
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#define ll long long
using namespace std;
ll get_pow(ll x,ll n){
ll ans=1;
while(n){
if(n&1){
ans=x*ans;
}
x=x*x;
n>>=1;
}
return ans;
}
int main(void)
{
ll a,b;
cin>>a>>b;
cout<<get_pow(a,b)<<endl;
return 0;
}
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#define ll long long
using namespace std;
ll get_pow(ll x,ll n){
ll ans=1;
while(n){
if(n&1){
ans=x*ans;
}
x=x*x;
n>>=1;
}
return ans;
}
int main(void)
{
ll a,b;
cin>>a>>b;
cout<<get_pow(a,b)<<endl;
return 0;
}
0 0
- 快速矩阵快速幂
- 快速幂,快速幂取模
- 快速幂 + 快速幂取模
- 快速幂 快速幂取模
- 快速幂&&快速乘法
- 快速幂&快速乘
- 快速幂 快速乘法
- 快速幂 快速幂取模
- 快速幂+快速乘法
- 【快速幂】【快速幂取模】
- 快速乘法-快速幂
- 快速乘/快速幂/矩阵快速幂
- 快速乘 快速幂 矩阵快速幂
- 快速幂,快速幂取模,矩阵快速幂
- 快速幂
- 快速幂
- 快速幂
- 快速幂
- js高程笔记
- JAVA-常用集合
- MySql 官方存储引擎
- 用python+selenium实现一步到达学者网的作业
- mysql实现分页查询
- 快速幂
- 搭建maven环境
- VS2012 asp.net开发之“IIS配置网站”
- sql语句使用-插入列与连接查询
- 关系数据库
- 编程题:旋转数组的最小数字
- 【特征匹配】ORB原理与源码解析
- 递推递归练习 P 二分查找
- eclipse中格式化代码快捷键Ctrl+Shift+F失效的原因以及解决办法