函数汇总

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int f1(int x){
	if(x>9999){
		return x;
	}
	return f1(x*2-1);
}
long long quick_pow(long long a,long long b){
	if(b==0) return a;
	 else if(b%2==0){
	 	b/=2;
	 	return quick_pow(a,b)*quick_pow(a,b);
	 }
	 else {
	 	b/=2;
	 	return quick_pow(a,b)*quick_pow(a,b)*a;
	 }
}
long long quick_pow(long long a,long long b,long long k){
	if(b==0) return 1%k;
    if(b==1) return a%k;
     else if(b%2==0){
        b/=2;
        long long c=quick_pow(a,b,k)%k;
        return (c%k*c%k)%k;
     }
     else {
        b/=2;
        long long c=quick_pow(a,b,k)%k;
        return (c%k*c%k*a%k)%k;
     }
}
int gcd(int x,int y){
	return x%y==0?y:gcd(y,x%y);
}
int n;
int quickPower(int a,int b){
	int ans=1;
	while(b){
		if(b & 1) ans *= a;
		a *= a;
		n >>= 1 ;
	}
	return ans;
}
int main(){
	printf("%d\n",gcd(2,17));
	printf("%lld",quick_pow(2,17));
	return 0;
}

posted @ 2019-12-19 19:52  刘子闻  阅读(123)  评论(0)    收藏  举报