diff --git a/algorithms/math/binary_exponentiation.cpp b/algorithms/math/binary_exponentiation.cpp index c3cf0fd3271afe689de8dcca9e0e4b36c0862393..ff4bd97c5278e3f48e7a93d9673a3f98787d5c61 100644 --- a/algorithms/math/binary_exponentiation.cpp +++ b/algorithms/math/binary_exponentiation.cpp @@ -3,20 +3,22 @@ /// Complexity (Time): O(log n) /// Complexity (Space): O(1) -/// Returns x^n in O(log n) time -/// @param x number -/// @param n exponent -template <typename T> -T fast_pow(T x, ll n) { - T ans = 1; +struct BinaryExponentiation { - while (n) { - if (n & 1) - ans = ans * x; + /// Returns x^n in O(log n) time + /// @param x number + /// @param n exponent + ll fast_pow(ll x, ll n) { + ll ans = 1; - n >>= 1; - x = x * x; - } + while (n) { + if (n & 1) + ans = ans * x; + + n >>= 1; + x = x * x; + } - return ans; -} + return ans; + } +}; diff --git a/algorithms/paradigm/ternary_search.cpp b/algorithms/paradigm/ternary_search.cpp index 6e462ac52c7b11c26c1b3c1fe194e4d42e426a47..3b00840befc8ff514bd60fa61762ed9c26a9d53d 100644 --- a/algorithms/paradigm/ternary_search.cpp +++ b/algorithms/paradigm/ternary_search.cpp @@ -4,7 +4,6 @@ /// Complexity (Space): O(1) struct TernarySearch { - const double EPS = 1e-6; /// Unimodal function double f(double x) { diff --git a/contests/Cadernaveis/BALE11.cpp b/contests/Cadernaveis/BALE11.cpp index 9aa2fb8a6ba41bf841b2d3c6984b4371a8d4980b..4b0729f9276d94f6e9c6624f2b9c0c22c68bd6ef 100644 --- a/contests/Cadernaveis/BALE11.cpp +++ b/contests/Cadernaveis/BALE11.cpp @@ -32,13 +32,11 @@ int query(int idx) { return sum; } - void update(int idx, int val) { for (; idx <= MAX; idx += (idx & -idx)) tree[idx] += val; } - int main() { ios::sync_with_stdio(0); cin.tie(0); diff --git a/contests/Cadernaveis/URI1850.cpp b/contests/Cadernaveis/URI1850.cpp index ae800d44665f75c10a2a4b50030aea4d50e4ec33..a75ef8658984bc52abdb8dfe64ea062ac0167e20 100644 --- a/contests/Cadernaveis/URI1850.cpp +++ b/contests/Cadernaveis/URI1850.cpp @@ -48,7 +48,6 @@ int main() { while (!Q.empty()) { elem curr = Q.front(); Q.pop(); - cont[curr.fi.fi][curr.fi.se][curr.se.fi] = 1; if (mat[curr.fi.fi][curr.fi.se] == '*') return cout << curr.se.se << ende, 0; @@ -63,14 +62,14 @@ int main() { if (mat[x][y] >= 'A' && mat[x][y] <= 'G') { if (msk & (1 << (mat[x][y] - 'A'))) { - //cont[x][y][msk] = 1; + cont[x][y][msk] = 1; Q.push({{x, y}, {msk, curr.se.se + 1}}); } } else { if (mat[x][y] >= 'a' && mat[x][y] <= 'g') msk |= (1 << (mat[x][y] - 'a')); - //cont[x][y][msk] = 1; + cont[x][y][msk] = 1; Q.push({{x, y}, {msk, curr.se.se + 1}}); } }