結果
問題 | No.1269 I hate Fibonacci Number |
ユーザー | 👑 rin204 |
提出日時 | 2023-12-29 16:21:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,249 bytes |
コンパイル時間 | 546 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 90,680 KB |
最終ジャッジ日時 | 2024-09-27 16:15:42 |
合計ジャッジ時間 | 26,145 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
62,312 KB |
testcase_01 | AC | 44 ms
55,340 KB |
testcase_02 | AC | 143 ms
76,800 KB |
testcase_03 | AC | 48 ms
60,304 KB |
testcase_04 | AC | 58 ms
64,372 KB |
testcase_05 | AC | 48 ms
60,840 KB |
testcase_06 | AC | 48 ms
60,168 KB |
testcase_07 | AC | 49 ms
61,728 KB |
testcase_08 | AC | 55 ms
63,824 KB |
testcase_09 | AC | 48 ms
61,508 KB |
testcase_10 | AC | 48 ms
61,132 KB |
testcase_11 | AC | 55 ms
64,844 KB |
testcase_12 | AC | 50 ms
61,392 KB |
testcase_13 | AC | 1,853 ms
78,208 KB |
testcase_14 | AC | 2,392 ms
78,444 KB |
testcase_15 | AC | 287 ms
76,672 KB |
testcase_16 | AC | 1,727 ms
78,648 KB |
testcase_17 | AC | 110 ms
76,676 KB |
testcase_18 | AC | 1,932 ms
78,240 KB |
testcase_19 | AC | 1,295 ms
77,300 KB |
testcase_20 | AC | 383 ms
76,948 KB |
testcase_21 | AC | 1,228 ms
77,708 KB |
testcase_22 | AC | 982 ms
77,332 KB |
testcase_23 | AC | 1,102 ms
77,148 KB |
testcase_24 | AC | 572 ms
77,128 KB |
testcase_25 | AC | 687 ms
77,020 KB |
testcase_26 | AC | 128 ms
76,820 KB |
testcase_27 | AC | 56 ms
66,088 KB |
testcase_28 | AC | 381 ms
77,052 KB |
testcase_29 | AC | 607 ms
76,992 KB |
testcase_30 | AC | 279 ms
76,844 KB |
testcase_31 | TLE | - |
testcase_32 | AC | 747 ms
77,268 KB |
testcase_33 | TLE | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
from collections import deque class AhoCorasick: def __init__(self, words=None): if words is None: self.words = [] else: self.words = words def register(self, word): self.words.append(word) def build(self): self.children = [{}] self.match = [[]] for i, word in enumerate(self.words): self._register(i, word) self.failure = [0] * len(self.children) self._create_failure() def _register(self, i, word): k = 0 for s in word: if s in self.children[k]: k = self.children[k][s] else: le = len(self.children) self.children[k][s] = le self.children.append({}) self.match.append([]) k = le self.match[k].append(i) def _create_failure(self): queue = deque(self.children[0].values()) while queue: k = queue.popleft() b = self.failure[k] for s, j in self.children[k].items(): self.failure[j] = self._next(b, s) self.match[j] += self.match[self.failure[j]] queue.append(j) def _next(self, k, s): while 1: if s in self.children[k]: return self.children[k][s] elif k == 0: return 0 k = self.failure[k] def search(self, text): k = 0 le = len(text) matched = [[] for _ in range(le)] for i, s in enumerate(text): k = self._next(k, s) for m in self.match[k]: matched[i - len(self.words[m]) + 1].append(m) return matched MOD = 10**9 + 7 n, l, r = map(int, input().split()) aho = AhoCorasick() a = 1 b = 1 while b <= r: if l <= b <= r: aho.register(str(b)) a, b = b, a + b aho.build() m = len(aho.children) dp = [0] * m dp[0] = 1 for _ in range(n): ndp = [0] * m for k, v in enumerate(dp): for i in range(10): nex = aho._next(k, str(i)) if aho.match[nex]: continue ndp[nex] += v dp = [d % MOD for d in ndp] print((sum(dp) - 1) % MOD)