結果

問題 No.1810 RGB Biscuits
ユーザー ytftytft
提出日時 2022-02-13 12:44:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 912 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 57,044 KB
最終ジャッジ日時 2023-09-11 15:25:25
合計ジャッジ時間 13,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 240 ms
29,436 KB
testcase_01 AC 140 ms
29,544 KB
testcase_02 AC 135 ms
29,720 KB
testcase_03 AC 142 ms
29,616 KB
testcase_04 AC 141 ms
29,664 KB
testcase_05 AC 886 ms
29,640 KB
testcase_06 AC 912 ms
29,608 KB
testcase_07 AC 904 ms
29,604 KB
testcase_08 AC 909 ms
29,660 KB
testcase_09 AC 900 ms
29,616 KB
testcase_10 AC 579 ms
29,548 KB
testcase_11 AC 154 ms
29,548 KB
testcase_12 AC 148 ms
29,644 KB
testcase_13 AC 150 ms
29,616 KB
testcase_14 AC 256 ms
29,616 KB
testcase_15 AC 153 ms
29,620 KB
testcase_16 AC 173 ms
29,552 KB
testcase_17 AC 488 ms
29,696 KB
testcase_18 AC 503 ms
29,604 KB
testcase_19 AC 140 ms
29,616 KB
testcase_20 AC 134 ms
29,680 KB
testcase_21 AC 210 ms
57,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
A,B=map(int,input().split())
N=int(input())
a=np.array([[1,0,0],[0,1,0],[A,B,1]])
b=np.array([[0,0,1],[1,0,0],[0,0,0]])
mod=10**9+7
for k in range(N):
	t=int(input())
	ans=a if t%2 else np.array([[1,0,0],[0,1,0],[0,0,1]])
	temp=b@a
	rem=t//2
	while rem:
		if rem%2:
			ans=ans@temp
		temp=temp@temp
		for i in range(3):
			for j in range(3):
				ans[i][j]%=mod
				temp[i][j]%=mod
		rem//=2
	print((np.array([[1,1,1]])@ans@np.array([[1],[1],[0]]))[0][0]%mod)
0