add trick example of greatest-common-divisor, knuth-morris-pratt, primality-test, quick-pow, split-text
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
long long quick_pow(int base, int power) {
|
||||
long long ans = 1;
|
||||
while (power > 0) {
|
||||
if (power & 1) {
|
||||
ans *= base;
|
||||
}
|
||||
base *= base;
|
||||
power >>= 1;
|
||||
}
|
||||
return ans;
|
||||
}
|
Reference in New Issue
Block a user