結果

問題 No.53 悪の漸化式
ユーザー 双六双六
提出日時 2020-07-26 15:38:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 72,008 KB
最終ジャッジ日時 2023-09-11 01:58:11
合計ジャッジ時間 3,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,592 KB
testcase_01 AC 89 ms
71,540 KB
testcase_02 AC 90 ms
71,584 KB
testcase_03 AC 93 ms
71,660 KB
testcase_04 AC 90 ms
71,656 KB
testcase_05 AC 90 ms
71,644 KB
testcase_06 AC 90 ms
71,628 KB
testcase_07 AC 90 ms
71,756 KB
testcase_08 AC 90 ms
71,636 KB
testcase_09 AC 90 ms
71,436 KB
testcase_10 AC 89 ms
71,584 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 9; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def mul(A, B):
	C = [[0] * len(B[0]) for i in range(len(A))]
	for i in range(len(A)):
		for k in range(len(B)):
			for j in range(len(B[0])):
				C[i][j] = (C[i][j] + A[i][k] * B[k][j])
	return C

def matrixPow(A, n, N):
	B = [[0] * N for i in range(N)]
	for i in range(N):
		B[i][i] = 1

	while n > 0:
		if n & 1 == 1:
			B = mul(A, B)
		A = mul(A, A)
		n = n >> 1

	return B


#処理内容
def main():
	N = int(input())
	A = [[19 / 4, -3], [1, 0]]

	B = matrixPow(A, N, 2)
	# print(B)
	anspre = mul(B, [[3], [4]])
	ans = anspre[1][0]
	print(ans)



if __name__ == '__main__':
	main()
0