# Problems — Level 2: Modular Arithmetic

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

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

প্রতিটা note লেখা হয় [../../../templates/math-problem-note-template.md](../../../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](../README.md)-এর recommended order ধরো — clock model আগে, Fermat পরে
2. নিজে 20-30 মিনিট চেষ্টা, তারপর concept-notes
3. নিজে সমাধান করার অগ্রগতি আলাদা খাতায় বা tracker-এ রাখো। “নোট আছে” কেবল ব্যাখ্যার উপস্থিতি বোঝায়।

## Tracker table

| # | Problem | Difficulty | Pattern | Inherits from | Source | Note file | নোটের অবস্থা |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 026 | Remainder Basics | Easy | mod basics | 001 | Classic exercise | [026-remainder-basics.md](026-remainder-basics.md) | নোট আছে |
| 027 | Modular Addition | Easy | (a+b)%m | 026 | Classic exercise | [027-modular-addition.md](027-modular-addition.md) | নোট আছে |
| 028 | Modular Multiplication | Easy | (a*b)%m | 027 | Classic exercise | [028-modular-multiplication.md](028-modular-multiplication.md) | নোট আছে |
| 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](029-modular-exponentiation.md) | নোট আছে |
| 030 | Fast Power | Medium | binary exponentiation | 029 | LeetCode Pow(x, n) — <https://leetcode.com/problems/powx-n/> | [030-fast-power.md](030-fast-power.md) | নোট আছে |
| 031 | Large Number Mod | Medium | digit-by-digit mod | 026 | Classic exercise | [031-large-number-mod.md](031-large-number-mod.md) | নোট আছে |
| 032 | Modular Inverse Basic | Medium | Fermat inverse | 029 | CP-Algorithms — <https://cp-algorithms.com/algebra/module-inverse.html> | [032-modular-inverse-basic.md](032-modular-inverse-basic.md) | নোট আছে |
| 033 | Fermat Little Theorem | Medium | a^(p-1) ≡ 1 | 029 | CP-Algorithms module-inverse page | [033-fermat-little-theorem.md](033-fermat-little-theorem.md) | নোট আছে |
| 034 | nCr mod Prime | Hard | factorial + inverse | 032, 039 | CP-Algorithms — <https://cp-algorithms.com/combinatorics/binomial-coefficients.html> | [034-ncr-mod-prime.md](034-ncr-mod-prime.md) | নোট আছে |
| 035 | Modular Division | Medium | multiply by inverse | 032 | Classic exercise | [035-modular-division.md](035-modular-division.md) | নোট আছে |
| 036 | Cyclic Remainder Pattern | Easy | cycle in powers | 026 | Classic exercise | [036-cyclic-remainder-pattern.md](036-cyclic-remainder-pattern.md) | নোট আছে |
| 037 | Clock Arithmetic Problems | Easy | clock model | 026 | Classic exercise | [037-clock-arithmetic.md](037-clock-arithmetic.md) | নোট আছে |
| 038 | Hashing with Mod | Medium | polynomial hash | 028 | CP-Algorithms — <https://cp-algorithms.com/string/string-hashing.html> | [038-hashing-with-mod.md](038-hashing-with-mod.md) | নোট আছে |

## 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](../concept-notes.md)। ঘড়ির ছবি → [../visualization-ideas.md](../visualization-ideas.md)।
