結果

問題 No.1810 RGB Biscuits
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-13 22:05:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 353 ms / 2,000 ms
コード長 1,235 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-28 20:05:54
合計ジャッジ時間 4,231 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
11,648 KB
testcase_01 AC 39 ms
11,648 KB
testcase_02 AC 37 ms
11,648 KB
testcase_03 AC 40 ms
11,648 KB
testcase_04 AC 39 ms
11,648 KB
testcase_05 AC 332 ms
11,776 KB
testcase_06 AC 352 ms
11,904 KB
testcase_07 AC 351 ms
11,776 KB
testcase_08 AC 353 ms
11,776 KB
testcase_09 AC 350 ms
11,776 KB
testcase_10 AC 222 ms
11,776 KB
testcase_11 AC 40 ms
11,648 KB
testcase_12 AC 43 ms
11,648 KB
testcase_13 AC 43 ms
11,648 KB
testcase_14 AC 86 ms
11,776 KB
testcase_15 AC 43 ms
11,648 KB
testcase_16 AC 53 ms
11,648 KB
testcase_17 AC 179 ms
11,776 KB
testcase_18 AC 184 ms
11,776 KB
testcase_19 AC 38 ms
11,648 KB
testcase_20 AC 37 ms
11,776 KB
testcase_21 AC 68 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from copy import deepcopy as dcopy
import math
import sys
sys.setrecursionlimit(10**6)
def input():
    return sys.stdin.readline().rstrip()
def getN():
	return int(sys.stdin.readline())
def getNs():
	return map(int,sys.stdin.readline().split())
def getList():
	return list(map(int,sys.stdin.readline().split()))
def strinps(n):
	return [sys.stdin.readline().rstrip() for _ in range(n)]
pi = 3.141592653589793
mod = 10**9+7
MOD = 998244353
INF = math.inf
dx = [1,0,-1,0];	dy = [0,1,0,-1]

def prod_mat(A, B):
	res = [[0, 0],
		[0, 0]]
	for i in range(2):
		for j in range(2):
			for k in range(2):
				res[i][j] += A[i][k] * B[k][j]
				res[i][j] %= mod
	return res

def exp_mat(A, n):
	res = [[1, 0],
		[0, 1]]
	while(n):
		if(n & 1):
			res = prod_mat(A, res)
		n >>= 1
		A = prod_mat(A, A)
	return res

"""
Main Code
"""

a,b = getNs()
n = getN()
t = [getN() for _ in [0] * n]
p = [[a, b],
	 [1, 0]]
for i in t:
	k = i >> 1
	r = i & 1
	q = exp_mat(p, k)
	v = [q[0][0] + q[0][1], q[1][0] + q[1][1]]
	if(r):
		print((v[0] + v[1] + v[0] * a % mod + v[1] * b % mod) % mod)
	else:
		print((v[0] + v[1]) % mod)
0