Hey hey will be added
When you want to perform the same processing in the state of N, N-1, etc. https://atcoder.jp/contests/abc115/tasks/abc115_d
When you want to make the nesting of loops variable https://atcoder.jp/contests/abc114/tasks/abc114_c
In the first place, it is also a part like the definition of a recursive function. When considering N, N-1, ..., i, ..., 2, 1, etc., the same processing is performed for the Nth, ith, and 1st. As is common with recursive functions, it is important to clarify the termination conditions.
When solving the problem of competitive programming, there are times when you want to make the nesting of loops variable. For example, when you want to create a double loop when the input is 10, and a triple loop when the input is 100. After making the nesting of the for statement work at the maximum length, there is no solution such as creating a flag. However, it is better to remember recursion because the application will be difficult to work.
The basis of recursion is like searching for similar states.
Recommended Posts