На фондовом рынке города цены на акции данного дня рассчитываются как 3-хкратная цена предыдущего дня плюс 4-хкратная цена предыдущего дня. Учитывая цены на 1-й и 2-й день, ответьте на Q вопросов, спрашивая вас о цене акций на N-й день.
**Input Format:**
The first line of the input contains two space-separated integers A and B, denoting the initial price of stock on day 1 and day 2
The next line of the input contains an integer Q denoting the number of queries.
The next line contains Q space-separated integers each denoting the number of the day for which the stock price is asked.
Формат вывода:
Print one line containing Q space-separated integer, ith of them denoting the value of the stock price on ith day. Since the price on ith day can be larger than the value contained in 32 bit integer, answer it modulo 10^9+7.
Вот что я попробовал:
inputs = list(map(int, input().split(' ')))
Q = int(input())
queries = list(map(int, input().split(' ')))
mod=(10**9)+7
for i in range(2, 1001):
inputs.append(3 * inputs[i - 1] + 4 * inputs[i - 2])
for j in queries:
print(inputs[j-1]%mod,end=' ')
Input Given:
4 5
4
1 2 3 998
My Output:
4 5 31 83571769
Desired Output:
4 5 31 39933786
Есть ли конкретный способ использования по модулю 10**9+7
?