結果

問題 No.1704 Many Bus Stops (easy)
ユーザー Kiri8128Kiri8128
提出日時 2021-10-08 22:54:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 617 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 83,716 KB
最終ジャッジ日時 2023-09-30 12:06:10
合計ジャッジ時間 19,560 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,644 KB
testcase_01 AC 556 ms
79,560 KB
testcase_02 AC 258 ms
77,960 KB
testcase_03 AC 262 ms
78,360 KB
testcase_04 AC 260 ms
78,284 KB
testcase_05 AC 349 ms
79,872 KB
testcase_06 AC 314 ms
79,800 KB
testcase_07 AC 256 ms
78,580 KB
testcase_08 AC 262 ms
78,060 KB
testcase_09 AC 258 ms
78,008 KB
testcase_10 AC 259 ms
78,004 KB
testcase_11 AC 274 ms
78,360 KB
testcase_12 AC 318 ms
80,528 KB
testcase_13 AC 265 ms
78,344 KB
testcase_14 AC 262 ms
78,464 KB
testcase_15 AC 260 ms
78,552 KB
testcase_16 AC 266 ms
77,936 KB
testcase_17 AC 267 ms
78,044 KB
testcase_18 AC 310 ms
81,820 KB
testcase_19 AC 259 ms
77,960 KB
testcase_20 AC 285 ms
79,492 KB
testcase_21 AC 260 ms
78,172 KB
testcase_22 AC 563 ms
79,260 KB
testcase_23 AC 554 ms
78,784 KB
testcase_24 AC 562 ms
79,756 KB
testcase_25 AC 558 ms
79,108 KB
testcase_26 AC 560 ms
79,424 KB
testcase_27 AC 568 ms
78,888 KB
testcase_28 AC 617 ms
83,716 KB
testcase_29 AC 556 ms
79,084 KB
testcase_30 AC 554 ms
79,364 KB
testcase_31 AC 594 ms
82,208 KB
testcase_32 AC 570 ms
79,432 KB
testcase_33 AC 562 ms
79,400 KB
testcase_34 AC 558 ms
79,308 KB
testcase_35 AC 557 ms
79,316 KB
testcase_36 AC 567 ms
79,280 KB
testcase_37 AC 574 ms
79,192 KB
testcase_38 AC 598 ms
81,428 KB
testcase_39 AC 563 ms
79,040 KB
testcase_40 AC 555 ms
79,436 KB
testcase_41 AC 568 ms
78,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mmult(A, B):
    global mod
    n, m, l = len(A), len(B), len(B[0])
    ret = [[0] * l for _ in range(n)]
    for i in range(n):
        for j in range(m):
            for k in range(l):
                ret[i][k] = (ret[i][k] + A[i][j] * B[j][k]) % mod
    return ret
def mpow(A, n):
    if n == 1: return A
    if n == 0: return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))]
    return mmult(mpow(A, n - 1), A) if n % 2 else mpow(mmult(A, A), n // 2)

mod = 10 ** 9 + 7
i3 = (mod + 1) // 3
X = [[i3, 0, 0, 0, i3, i3], [0, i3, 0, i3, 0, i3], [0, 0, i3, i3, i3, 0], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]

T = int(input())
for _ in range(T):
    print(mpow(X, int(input()))[0][0])
0