快速幂模版

mac2022-07-05  41

#include<iostream> #include<cstdio> #include<cmath> using namespace std; int f(int x,int n) { int now=1; while(n) { if(n&1) { now=now*x; } x=x*x; n>>=1; } return now; } int main() { int x,n; cin>>x>>n; cout<<f(x,n); return 0; }

 

转载于:https://www.cnblogs.com/sssy/p/6680069.html

最新回复(0)