結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2015-12-18 21:19:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 892 bytes |
コンパイル時間 | 520 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 26,368 KB |
最終ジャッジ日時 | 2024-09-16 08:40:26 |
合計ジャッジ時間 | 1,947 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 RE * 7 |
ソースコード
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array UNDETERMINED = -1 MODULUS = 10 ** 9 + 7 ONE = 1 TWO = 2 THREE = 2 class Kenkenpa(object): def __init__(self, number, one=ONE, two=TWO, three=THREE, modulus=MODULUS): self.number = number self.modulus = modulus self.memo = array.array("q", [UNDETERMINED] * (max(4, number + 1))) self.memo[1] = one self.memo[2] = two self.memo[3] = three def count_courses(self, n=None): if n is None: n = self.number m = self.memo[n] if m != UNDETERMINED: return m else: result = (self.count_courses(n - 2) + self.count_courses(n - 3)) % self.modulus self.memo[n] = result return result if __name__ == "__main__": print(Kenkenpa(number=int(input())).count_courses())