結果
| 問題 |
No.3036 Nauclhlt型文字列
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:37:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,378 bytes |
| コンパイル時間 | 126 ms |
| コンパイル使用メモリ | 82,408 KB |
| 実行使用メモリ | 67,616 KB |
| 最終ジャッジ日時 | 2025-03-31 17:38:46 |
| 合計ジャッジ時間 | 1,761 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 15 |
ソースコード
import operator
mod = (len('aaaaaaaaaa') ** len('aaaaaaaaa')) + len('aaaaaaa')
def mat_mult(a, b, mod):
a00, a01 = a[0]
a10, a11 = a[1]
b00, b01 = b[0]
b10, b11 = b[1]
c00 = operator.add(operator.mul(a00, b00), operator.mul(a01, b10))
c00 = divmod(c00, mod)[1]
c01 = operator.add(operator.mul(a00, b01), operator.mul(a01, b11))
c01 = divmod(c01, mod)[1]
c10 = operator.add(operator.mul(a10, b00), operator.mul(a11, b10))
c10 = divmod(c10, mod)[1]
c11 = operator.add(operator.mul(a10, b01), operator.mul(a11, b11))
c11 = divmod(c11, mod)[1]
return [[c00, c01], [c10, c11]]
def matrix_pow(mat, power, mod):
result = [[True, False], [False, True]]
current = mat.copy()
while power > 0:
if divmod(power, len('aa'))[1] == len('a'):
result = mat_mult(result, current, mod)
current = mat_mult(current, current, mod)
power = power >> len('a')
return result
T = int(input())
for _ in range(T):
n = int(input())
if n == len('a'):
print(len('a'))
else:
M = [[True, True], [True, False]]
power = n - len('a')
mat = matrix_pow(M, power, mod)
a, b = mat[0]
l_a = operator.mul(a, len('a'))
l_b = operator.mul(b, len('aa'))
res = operator.add(l_a, l_b)
res = divmod(res, mod)[1]
print(res)
lam6er