Skip to content

Problems — Level 2: Modular Arithmetic

এই folder-এ Level 2-এর 13টা problem-এর note থাকবে। প্রতিটার জন্য আলাদা .md file — নিজের ভাষায় বোঝা, ঘড়ির ছবি, dry run, code, আর ভুলের তালিকা।

কীভাবে problem গুলো use করবে?

প্রতিটা note লেখা হয় ../../../templates/math-problem-note-template.md follow করে — ২০টা section-এর template (problem নিজের ভাষায় → brute force → optimization → dry run → complexity → এক লাইনের শিক্ষা)। এই level-এ dry run section-টা সোনার খনি — mod-এর হিসাব হাতে করে Python-এর সাথে মিলিয়ে দেখাটাই আসল শেখা; না মিললে বুঝবে হাতের হিসাবে ফাঁক আছে, আর সেই ফাঁক খোঁজাই practice।

নিয়ম:

  1. ../README.md-এর recommended order ধরো — clock model আগে, Fermat পরে
  2. নিজে 20-30 মিনিট চেষ্টা, তারপর concept-notes
  3. Solve হলে Status planneddone

Tracker table

# Problem Difficulty Pattern Inherits from Source Note file Status
026 Remainder Basics Easy mod basics 001 Classic exercise 026-remainder-basics.md planned
027 Modular Addition Easy (a+b)%m 026 Classic exercise 027-modular-addition.md planned
028 Modular Multiplication Easy (a*b)%m 027 Classic exercise 028-modular-multiplication.md planned
029 Modular Exponentiation Medium square & multiply 028 CP-Algorithms — https://cp-algorithms.com/algebra/binary-exp.html, CSES Exponentiation — https://cses.fi/problemset/task/1095 029-modular-exponentiation.md planned
030 Fast Power Medium binary exponentiation 029 LeetCode Pow(x, n) — https://leetcode.com/problems/powx-n/ 030-fast-power.md planned
031 Large Number Mod Medium digit-by-digit mod 026 Classic exercise 031-large-number-mod.md planned
032 Modular Inverse Basic Medium Fermat inverse 029 CP-Algorithms — https://cp-algorithms.com/algebra/module-inverse.html 032-modular-inverse-basic.md planned
033 Fermat Little Theorem Medium a^(p-1) ≡ 1 029 CP-Algorithms module-inverse page 033-fermat-little-theorem.md planned
034 nCr mod Prime Hard factorial + inverse 032, 039 CP-Algorithms — https://cp-algorithms.com/combinatorics/binomial-coefficients.html 034-ncr-mod-prime.md planned
035 Modular Division Medium multiply by inverse 032 Classic exercise 035-modular-division.md planned
036 Cyclic Remainder Pattern Easy cycle in powers 026 Classic exercise 036-cyclic-remainder-pattern.md planned
037 Clock Arithmetic Problems Easy clock model 026 Classic exercise 037-clock-arithmetic.md planned
038 Hashing with Mod Medium polynomial hash 028 CP-Algorithms — https://cp-algorithms.com/string/string-hashing.html 038-hashing-with-mod.md planned

Problem-দের পারিবারিক গাছ

001 (parity, Level 0)
   └─> 026 (remainder basics) ─┬─> 027 (add) ─> 028 (multiply) ─┬─> 029 (mod exp) ─> 030 (fast power)
                               │                                └─> 038 (hashing)
                               ├─> 031 (large number mod)              │
                               ├─> 036 (cyclicity)            029 ─> 033 (Fermat) 
                               └─> 037 (clock problems)       029 ─> 032 (inverse) ─> 035 (division)
                                          032 + 039 (factorial, Level 3) ─> 034 (nCr mod p — Hard)

লক্ষ করো 034 (nCr mod Prime)-এর একটা পা Level 3-এর 039 (Factorial)-এ — চাইলে 034 শুরুর আগে Level 3-এর প্রথম problem-টা সেরে এসো, অথবা 034-কে Level 3-এর মাঝখানে আবার revisit করো। দুই পথই ঠিক।

একটা ছোট পরামর্শ

এই level-এ প্রতিটা problem-এ একটা অভ্যাস গড়ো: নিজের উত্তর brute force দিয়ে verify করা। যেমন fast power লিখলে পাশে সরল loop-power লিখে ছোট input-এ দুটো মেলাও; inverse বের করলে a * inv % p == 1 assert করো। mod-এর bug চোখে দেখা যায় না — শুধু verify-তেই ধরা পড়ে। আর pow(a, b, m) built-in থাকলেও অন্তত একবার নিজে square-and-multiply লিখো — interview-তে built-in চলবে না।

Concept ঝালাই → ../concept-notes.md। ঘড়ির ছবি → ../visualization-ideas.md