Skip to content

Add worst case tests for fixed dlog.#1392

Merged
maspypy merged 2 commits into
yosupo06:masterfrom
NicholasPatrick:fixed_dlog_worst_case_tests
Apr 8, 2026
Merged

Add worst case tests for fixed dlog.#1392
maspypy merged 2 commits into
yosupo06:masterfrom
NicholasPatrick:fixed_dlog_worst_case_tests

Conversation

@NicholasPatrick
Copy link
Copy Markdown
Contributor

big_safe_random

Pohlig-Hellman algorithm can be quite effective in existing tests, even for precomputation. Safe primes provide the worst case for Pohlig-Hellman. Example hack, note the slightly longer precompute time of 14ms compared to 12ms in sample in stderr.

big_safe_random_g2

Some solutions try to solve for discrete logarithm of $k$ via a reduction to $k, gk, g^2k, ...$ until one is "easy enough" to solve (e.g. when it's smooth or $k/p$ is very close to a fraction with a small denominator), treating this sequence as random. Such solutions will be slowed down when $g=2$ because if a particular value isn't suitable, twice that value is likely to not be suitable either.

Example of a solution being slower when $g=2$ because:

@maspypy
Copy link
Copy Markdown
Collaborator

maspypy commented Apr 8, 2026

I'll merge it, thank you!

@maspypy maspypy merged commit 3008e71 into yosupo06:master Apr 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants