結果

問題 No.314 ケンケンパ
ユーザー koyumeishikoyumeishi
提出日時 2015-12-07 01:02:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 629 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 6,196 KB
最終ジャッジ日時 2023-10-12 18:44:45
合計ジャッジ時間 1,250 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,060 KB
testcase_01 AC 11 ms
6,044 KB
testcase_02 AC 11 ms
6,188 KB
testcase_03 AC 11 ms
5,956 KB
testcase_04 AC 11 ms
5,992 KB
testcase_05 AC 11 ms
5,992 KB
testcase_06 AC 11 ms
6,060 KB
testcase_07 AC 11 ms
6,108 KB
testcase_08 AC 11 ms
5,988 KB
testcase_09 AC 11 ms
6,168 KB
testcase_10 AC 11 ms
6,068 KB
testcase_11 AC 11 ms
6,196 KB
testcase_12 AC 11 ms
6,116 KB
testcase_13 AC 12 ms
6,192 KB
testcase_14 AC 12 ms
6,196 KB
testcase_15 AC 12 ms
6,040 KB
testcase_16 AC 12 ms
5,968 KB
testcase_17 AC 11 ms
6,064 KB
testcase_18 AC 11 ms
6,176 KB
testcase_19 AC 12 ms
6,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
mat = [0,0,1,1,0,0,1,1,0]

mod = 1000000007

ret = [1,0,0,0,1,0,0,0,1]
while n>0 :
	if (n&1) == 1 :
		tmp = [0,0,0,0,0,0,0,0,0]
		for i in xrange(3) :
			for k in xrange(3) :
				for j in xrange(3) :
					tmp[i*3 + j] += ret[i*3 + k] * mat[k*3 + j]
					if tmp[i*3 + j] >= mod :
						tmp[i*3 + j] %= mod
		ret = tmp

	tmp_ = [0,0,0,0,0,0,0,0,0]
	for i in xrange(3) :
		for k in xrange(3) :
			for j in xrange(3) :
				tmp_[i*3 + j] += mat[i*3 + k] * mat[k*3 + j]
				if tmp_[i*3 + j] >= mod :
					tmp_[i*3 + j] %= mod
	mat = tmp_

	n = n>>1

ans = (ret[0*3 + 2] + ret[1*3 + 2] + ret[2*3 + 2]) % mod

print(ans)
0