結果
問題 | No.1704 Many Bus Stops (easy) |
ユーザー | mkawa2 |
提出日時 | 2021-10-08 23:24:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 273 ms / 2,000 ms |
コード長 | 1,497 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,144 KB |
実行使用メモリ | 78,316 KB |
最終ジャッジ日時 | 2024-07-23 07:25:31 |
合計ジャッジ時間 | 10,597 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
62,016 KB |
testcase_01 | AC | 224 ms
77,172 KB |
testcase_02 | AC | 166 ms
77,808 KB |
testcase_03 | AC | 174 ms
77,100 KB |
testcase_04 | AC | 169 ms
77,852 KB |
testcase_05 | AC | 167 ms
77,556 KB |
testcase_06 | AC | 168 ms
77,136 KB |
testcase_07 | AC | 170 ms
77,292 KB |
testcase_08 | AC | 170 ms
78,056 KB |
testcase_09 | AC | 178 ms
77,368 KB |
testcase_10 | AC | 169 ms
77,368 KB |
testcase_11 | AC | 171 ms
77,736 KB |
testcase_12 | AC | 171 ms
77,272 KB |
testcase_13 | AC | 174 ms
77,532 KB |
testcase_14 | AC | 176 ms
77,692 KB |
testcase_15 | AC | 166 ms
77,948 KB |
testcase_16 | AC | 172 ms
77,148 KB |
testcase_17 | AC | 173 ms
77,440 KB |
testcase_18 | AC | 173 ms
77,640 KB |
testcase_19 | AC | 173 ms
78,316 KB |
testcase_20 | AC | 183 ms
77,212 KB |
testcase_21 | AC | 170 ms
77,144 KB |
testcase_22 | AC | 268 ms
77,520 KB |
testcase_23 | AC | 257 ms
77,604 KB |
testcase_24 | AC | 263 ms
77,652 KB |
testcase_25 | AC | 267 ms
77,456 KB |
testcase_26 | AC | 260 ms
77,860 KB |
testcase_27 | AC | 272 ms
77,432 KB |
testcase_28 | AC | 261 ms
77,016 KB |
testcase_29 | AC | 269 ms
78,016 KB |
testcase_30 | AC | 269 ms
77,608 KB |
testcase_31 | AC | 265 ms
77,220 KB |
testcase_32 | AC | 270 ms
77,568 KB |
testcase_33 | AC | 263 ms
77,676 KB |
testcase_34 | AC | 265 ms
77,412 KB |
testcase_35 | AC | 265 ms
77,144 KB |
testcase_36 | AC | 273 ms
77,352 KB |
testcase_37 | AC | 266 ms
78,220 KB |
testcase_38 | AC | 268 ms
77,544 KB |
testcase_39 | AC | 261 ms
77,636 KB |
testcase_40 | AC | 265 ms
77,028 KB |
testcase_41 | AC | 266 ms
77,572 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (1, 0), (0, -1), (-1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**19 # md = 998244353 md = 10**9+7 def dot(aa, bb): h = len(aa) w = len(bb[0]) res = [[0]*w for _ in range(h)] for i, row in enumerate(aa): for j, col in enumerate(zip(*bb)): v = 0 # for a, b in zip(row, col): v += a*b # res[i][j] = v%md for a, b in zip(row, col): v += a*b%md res[i][j] = v%md return res def matpow(e): n = 4 res = [[1 if i == j else 0 for j in range(n)] for i in range(n)] i = 0 while e: if e & 1: res = dot(res, mm[i]) e >>= 1 i += 1 return res inv = pow(3, md-2, md) mat = [[0, 0, 0, inv] , [0, 0, inv*2, inv] , [1, 0, inv, 0] , [0, 1, 0, inv]] lim = 10**9+5 i = 1 mm = [] while i < lim: mm.append(mat) mat = dot(mat, mat) i <<= 1 for _ in range(II()): n = II() print(matpow(n)[2][2])