Skip to content

Math -> BSGS / Discrete Log

Recover the exponent in a^x ≡ b (mod m) with gcd reduction first and baby-step giant-step second, when square-root storage is still contest-safe.

  • Topic slug: math/bsgs-discrete-log
  • Tutorial page: Open tutorial
  • Ladder page: Open ladder
  • Repo problems currently tagged here: 1
  • Repo companion pages: 4
  • Curated external problems: 2

Microtopics

  • discrete-log
  • baby-step-giant-step
  • meet-in-the-middle
  • gcd-reduction
  • mod-inverse
  • minimum-exponent

Learning Sources

Source Type
cp-algorithms discrete logarithm Reference
OI Wiki BSGS Reference
Library Checker Discrete Logarithm Mod Practice

Practice Sources

Source Type
LibreOJ #6542 Practice
Codeforces problemset Practice

Repo Companion Material

Material Type
Discrete Log hot sheet quick reference
Discrete Logarithm Mod flagship note
Template Library exact starter route starter route
Chinese Remainder / Linear Congruences compare point

Curated External Problems

Core

Problem Source Difficulty Context Style Prerequisites Tags Why it fits
Discrete Logarithm Mod Library Checker Hard Discrete Logarithm Math; Meet-In-The-Middle; Implementation Modular Arithmetic; Extended Euclid; Square Root Decomposition Discrete Log; Meet In The Middle; GCD Reduction The cleanest verifier for the repo's exact route: general discrete log with gcd reduction and a minimum-answer BSGS implementation.

Stretch

Problem Source Difficulty Context Style Prerequisites Tags Why it fits
LibreOJ #6542 LibreOJ Hard Discrete Logarithm Math; Implementation Bsgs; Modular Arithmetic Template; Discrete Log A classic template-style benchmark once the first verifier route is already trusted.

Repo Problems

Code Title Fit Difficulty Pattern Note Solution
DISCRETELOGARITHMMOD Discrete Logarithm Mod primary hard - Note Code

Regeneration

python3 scripts/generate_problem_catalog.py