4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Python] 競技プログラミングで再帰関数を書くときはsys.setrecursionlimitで最大再帰数を上げる

Last updated at Posted at 2019-08-29

再帰数の上限がデフォルトで設定されていて、これを超えると例外が投げられる。

必要に応じて上げる。

>>> import sys
>>> sys.getrecursionlimit()  # 確認
1000
>>> sys.setrecursionlimit(10 ** 6)  # 変更
>>> sys.getrecursionlimit()  # 確認
1000000

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?