Utilization of recursive functions used in competition pros

Hey hey will be added

There is a high possibility of using recursive in such cases!

  1. When you want to perform the same processing in the state of N, N-1, etc. https://atcoder.jp/contests/abc115/tasks/abc115_d

  2. When you want to make the nesting of loops variable https://atcoder.jp/contests/abc114/tasks/abc114_c

easy explanation

  1. When you want to perform the same processing in the state of N, N-1, etc.

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.

  1. When you want to make the nesting of loops variable

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.

Summary

The basis of recursion is like searching for similar states.

Recommended Posts

Utilization of recursive functions used in competition pros
Summary of evaluation functions used in machine learning
Basic algorithms that can be used in competition pros
Can be used in competition pros! Python standard library
Memorandum on Memoization of recursive functions
Summary of methods often used in pandas
Summary of frequently used commands in matplotlib
Modules of frequently used functions in Python (such as reading external files)
Functions that can be used in for statements
Gacha written in python-Practice 3 ・ Addition of step-up gacha functions-
List of frequently used built-in functions and methods
Summary of what was used in 100 Pandas knocks (# 1 ~ # 32)
Full disclosure of methods used in machine learning
Summary of tools used in Command Line vol.8
Summary of tools used in Command Line vol.5
Fix the argument of the function used in map
Used from the introduction of Node.js in WSL environment
A collection of code often used in personal Python
A collection of commands frequently used in server management
List of Python code used in big data analysis
A note on handling variables in Python recursive functions
A collection of Excel operations often used in Python
List of my articles that may be useful in competition pros (updated from time to time)
[Scientific / technical calculation by Python] List of usage of (special) functions used in physics by using scipy