Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data_structure/binary_trie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ template <class Int, class Count = int> struct BinaryTrie {

// Count elements y such that x ^ y < thres
Count count_less_xor(Int x, Int thres) const {
if (thres <= 0) return Count();
if ((thres >> maxD) > 0) return subtree_sum[0];
Count ret = Count();
int now = 0;

Expand Down
1 change: 1 addition & 0 deletions data_structure/binary_trie.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Key v = bt.xor_min(t); // t ^ x (x は現在存在する値)の最小値を

- [Library Checker: Set Xor-Min](https://judge.yosupo.jp/problem/set_xor_min)
- [No.2977 Kth Xor Pair - yukicoder](https://yukicoder.me/problems/no/2977)
- [AtCoder Beginner Contest 451 G - Minimum XOR Walk](https://atcoder.jp/contests/abc451/tasks/abc451_g)
4 changes: 2 additions & 2 deletions number/primitive_root.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
// - 163577857 ( = (39 << 22) + 1 ) -> 23
// - 2 -> 1
// - 1 -> -1
long long find_smallest_primitive_root(long long n) {
inline long long find_smallest_primitive_root(long long n) {
std::vector<long long> fac;
const long long phi = FactorizeLonglong.euler_phi(n);
for (long long q : FactorizeLonglong(phi)) {
if (fac.empty() or fac.back() != q) fac.push_back(q);
}

for (long long g = 1; g < n; g++) {
if (std::__gcd(n, g) != 1) continue;
if (std::gcd(n, g) != 1) continue;
if (pow_mod<long long, __int128>(g, phi, n) != 1) return -1;
bool ok = true;
for (auto pp : fac) {
Expand Down
4 changes: 2 additions & 2 deletions number/test/binary_gcd.stress.test.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A" // DUMMY
#include "../binary_gcd.hpp"
#include <algorithm> // __gcd
#include <iostream>
#include <numeric>
using namespace std;

template <typename Int> void test_binary_gcd(Int lo, Int hi) {
for (Int x = lo; x <= hi; x++) {
for (Int y = lo; y <= hi; y++) {
auto g = __gcd<Int>(x, y);
auto g = gcd<Int>(x, y);
if (g < 0) g = -g;
if (binary_gcd(x, y) != g) {
cerr << "Did not match : (x, y) = " << x << ',' << y << ')' << endl;
Expand Down
5 changes: 3 additions & 2 deletions number/test/zeta_moebius_transform.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../modint.hpp"
#include <cassert>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

Expand Down Expand Up @@ -77,7 +78,7 @@ void test_gcdconv() {
vector<mint> x = vecgen(n), y = vecgen(n), z(n + 1);
auto conv = gcdconv(x, y);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) z[__gcd(i, j)] += x[i] * y[j];
for (int j = 1; j <= n; ++j) z[gcd(i, j)] += x[i] * y[j];
}
assert(conv == z);
}
Expand All @@ -91,7 +92,7 @@ void test_lcmconv() {
auto conv = lcmconv(x, y);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
int l = i * j / __gcd(i, j);
int l = i * j / gcd(i, j);
if (l <= n) z[l] += x[i] * y[j];
}
}
Expand Down
Loading