If the recursive function is implemented in Problem on AtCoder, it will be RE (Runtime Error). .. .. The cause was that the upper limit of the number of repetitions of the recursive function was set to 1000 by default. ※Python3.4.3
[in] import sys
[in] sys.getrecursionlimit()
[out] 1000
[in] sys.setrecursionlimit(1000000) #Set the upper limit to 1 million times
[in] sys.getrecursionlimit()
[out] 1000000
You need to be careful when implementing recursive functions in Python. ..
Recommended Posts