Abstract
This chapter deals with mathematical topics that are recurrent in competitive programming. We will both discuss theoretical results and learn how to use them in practice in algorithms. Section 11.1 discusses number-theoretical topics. We will learn algorithms for finding prime factors of numbers, techniques related to modular arithmetic, and efficient methods for solving integer equations. Section 11.2 explores ways to approach combinatorial problems: how to efficiently count all valid combinations of objects. The topics of this section include binomial coefficients, Catalan numbers, and inclusion-exclusion. Section 11.3 shows how to use matrices in algorithm programming. For example, we will learn how to make a dynamic programming algorithm more efficient by exploiting an efficient way to calculate matrix powers. Section 11.4 first discusses basic techniques for calculating probabilities of events and the concept of Markov chains. After this, we will see examples of algorithms that are based on randomness. Section 11.5 focuses on game theory. First we will learn to optimally play a simple stick game using nim theory, and after this, we will generalize the strategy to a wide range of other games.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
While the straightforward \(O(n^3)\) time algorithm is sufficient in competitive programming, there are theoretically more efficient algorithms. In 1969, Strassen [31] discovered the first such algorithm, now called Strassen’s algorithm, whose time complexity is \(O(n^{2.81})\). The best current algorithm, proposed by Le Gall [11] in 2014, works in \(O(n^{2.37})\) time.
- 2.
A deck of cards consists of 52 cards. Each card has a suit (spade \(\spadesuit \), diamond \(\diamondsuit \), club \(\clubsuit \), or heart \(\heartsuit \)) and a value (an integer between 1 and 13).
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this chapter
Cite this chapter
Laaksonen, A. (2017). Mathematics. In: Guide to Competitive Programming. Undergraduate Topics in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-319-72547-5_11
Download citation
DOI: https://doi.org/10.1007/978-3-319-72547-5_11
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-72546-8
Online ISBN: 978-3-319-72547-5
eBook Packages: Computer ScienceComputer Science (R0)