Number Theory

Euler totient, CRT, prime factorization, and modular arithmetic through 10 problems.

43 lessons
146 min

Lessons

1. Introduction to Number Theory

Mathematical foundations for CP

2m

2. Techniques Overview

What you'll learn

3m

3. Codeforces 1295D Same GCDs - Problem Statement

CF 1295D - count values with same GCD

3m1 problems

4. Codeforces 1295D Same GCDs - Solution

Reduce to totient calculation

3m

5. Codeforces 1295D Same GCDs - Implementation

Totient via prime factorization

5m1 problems

6. Codeforces 1295D Same GCDs - Example and Complexity Analysis

Square root factorization

3m

7. Codeforces 687B Remainders Game - Problem Statement

CF 687B - determine value from remainders

3m1 problems

8. Codeforces 687B Remainders Game - Why Naive Fails

Can't enumerate all possible x

3m

9. Codeforces 687B Remainders Game - Solution

Check prime power coverage

3m

10. Codeforces 687B Remainders Game - Implementation

Check prime power divisibility

5m1 problems

11. Codeforces 687B Remainders Game - Example and Complexity Analysis

Factorization plus linear scan

3m

12. Codeforces 1033D Divisors - Problem Statement

CF 1033D - factor product of semiprimes

3m1 problems

13. Codeforces 1033D Divisors - Why Naive Fails

Numbers are too large to factor directly

3m

14. Codeforces 1033D Divisors - Solution

GCD to find shared primes

3m

15. Codeforces 1033D Divisors - Implementation

GCD-based factorization

5m1 problems

16. Codeforces 1033D Divisors - Example and Complexity Analysis

Quadratic in input size

3m

17. Codeforces 1748D ConstructOR - Problem Statement

CF 1748D - find x with OR divisibility

3m1 problems

18. Codeforces 1748D ConstructOR - Solution

Use LCM for bit construction

3m

19. Codeforces 1748D ConstructOR - Implementation

Construct x from LCM

5m1 problems

20. Codeforces 1748D ConstructOR - Example and Complexity Analysis

Constant time construction

3m

21. Codeforces 1761D Carry Bit - Problem Statement

CF 1761D - count pairs with k carries

3m1 problems

22. Codeforces 1761D Carry Bit - Why Naive Fails

Exponential pair count

3m

23. Carry Bit - Key Insight

Carry sequence structure

3m

24. Codeforces 1761D Carry Bit - Solution

Count carry sequences

3m

25. Codeforces 1761D Carry Bit - Implementation

Direct formula with combinatorics

5m1 problems

26. Codeforces 1761D Carry Bit - Example and Complexity Analysis

Linear precomputation

3m

27. Codeforces 1244C The Football Season - Problem Statement

CF 1244C - find win/draw/loss counts

3m1 problems

28. Codeforces 1244C The Football Season - Solution

Small iteration on draws

3m

29. Codeforces 1244C The Football Season - Implementation

Iterate draws up to w

5m1 problems

30. Codeforces 1244C The Football Season - Example and Complexity Analysis

Linear in point values

3m

31. Codeforces 1493D GCD of an Array - Problem Statement

CF 1493D - dynamic GCD with updates

3m1 problems

32. Codeforces 1493D GCD of an Array - Why Naive Fails

Recomputing GCD is too slow

3m

33. Codeforces 1493D GCD of an Array - Solution

Track min exponent per prime

3m

34. Codeforces 1493D GCD of an Array - Implementation

Multiset per prime

5m1 problems

35. Codeforces 1493D GCD of an Array - Example and Complexity Analysis

Per-prime multiset operations

3m

36. Codeforces 1884D Counting Rhyme - Problem Statement

CF 1884D - count coprime pairs not dividing any element

3m1 problems

37. Codeforces 1884D Counting Rhyme - Why Naive Fails

Quadratic pair counting

3m

38. Counting Rhyme - Key Insight

Exact GCD via inclusion-exclusion

3m

39. Codeforces 1884D Counting Rhyme - Solution

Iterate by GCD value with validity check

3m

40. Codeforces 1884D Counting Rhyme - Implementation

Count by GCD with exclusion

5m1 problems

41. Codeforces 1884D Counting Rhyme - Example and Complexity Analysis

Harmonic sum complexity

3m

42. Quiz: Number Theory

Test your understanding

5m1 problems

43. Section Recap

What you've learned

3m

Ready to start learning?

Access all 43 lessons with interactive content and progress tracking.