add trick example of greatest-common-divisor, knuth-morris-pratt, primality-test, quick-pow, split-text

This commit is contained in:
2025-09-23 11:25:26 +08:00
parent 57dd0e9440
commit 5368fcd277
5 changed files with 78 additions and 0 deletions

View File

@@ -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;
}