結果
| 問題 |
No.1704 Many Bus Stops (easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-08 22:55:26 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 742 bytes |
| コンパイル時間 | 107 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 50,984 KB |
| 最終ジャッジ日時 | 2024-07-23 06:07:23 |
| 合計ジャッジ時間 | 4,654 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 40 |
ソースコード
import numpy as np
MOD = 10 ** 9 + 7
i3 = pow(3, -1, MOD)
def pow_matrix_mod(x, n, mod=MOD):
if not n:
return np.eye(len(x), dtype=object)
if n % 2 == 0:
return pow_matrix_mod(x @ x % mod, n // 2) % mod
else:
return x @ pow_matrix_mod(x @ x % mod, (n - 1) // 2) % mod
def solve(N):
x = np.array([1, 0, 0, 0, 0, 0], dtype=object)
A = np.array([[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]], dtype=object)
return (x @ pow_matrix_mod(A, N))[0] % MOD
T = int(input())
for _ in range(T):
print(solve(int(input())))