快速幂

快速幂

    static int pow(int a, int b) {
		int r = 1, base = a;
		while (b != 0) {
			if (b % 2 == 1)
				r *= base;
			base *= base;
			b /= 2;
		}
		return r;
	}
posted @ 2020-03-10 22:29  continued258  阅读(57)  评论(0)    收藏  举报