結果

問題 No.1810 RGB Biscuits
ユーザー irumo8202irumo8202
提出日時 2022-01-14 23:18:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 651 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,364 KB
最終ジャッジ日時 2024-04-30 17:17:08
合計ジャッジ時間 15,757 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 514 ms
44,108 KB
testcase_01 AC 513 ms
44,100 KB
testcase_02 AC 515 ms
43,840 KB
testcase_03 AC 523 ms
43,728 KB
testcase_04 AC 522 ms
43,848 KB
testcase_05 AC 623 ms
44,096 KB
testcase_06 AC 648 ms
44,104 KB
testcase_07 AC 651 ms
44,220 KB
testcase_08 AC 644 ms
43,840 KB
testcase_09 AC 649 ms
44,092 KB
testcase_10 AC 609 ms
44,356 KB
testcase_11 AC 535 ms
43,840 KB
testcase_12 AC 519 ms
43,844 KB
testcase_13 AC 514 ms
43,752 KB
testcase_14 AC 541 ms
43,732 KB
testcase_15 AC 516 ms
44,108 KB
testcase_16 AC 524 ms
43,712 KB
testcase_17 AC 592 ms
44,104 KB
testcase_18 AC 588 ms
44,096 KB
testcase_19 AC 516 ms
43,836 KB
testcase_20 AC 524 ms
44,364 KB
testcase_21 AC 548 ms
44,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

A, B = map(int, input().split())
n = int(input())
MOD = 10 ** 9 + 7

M1 = np.array([[1, 0, 0], [0, 1, 0], [A, B, 0]])
M2 = np.array([[0, 0, 1], [1, 0, 0], [0, 0, 0]])

M = M2 @ M1
doubling = [M1, M]

for i in range(61):
    doubling.append(doubling[-1] @ doubling[-1])
    doubling[-1] = np.mod(doubling[-1], MOD)

for i in range(n):
    T = int(input())
    V = np.array([1, 1, 0])
    for i in range(61)[::-1]:
        if T >> i & 1:
            V = doubling[i] @ V
            V = np.mod(V, MOD)

    print(np.sum(V) % MOD)
0