結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 468 ms
44,104 KB
testcase_01 AC 443 ms
44,224 KB
testcase_02 AC 445 ms
43,836 KB
testcase_03 AC 450 ms
44,104 KB
testcase_04 AC 458 ms
43,836 KB
testcase_05 AC 537 ms
44,236 KB
testcase_06 AC 571 ms
44,352 KB
testcase_07 AC 559 ms
44,104 KB
testcase_08 AC 557 ms
44,488 KB
testcase_09 AC 557 ms
43,844 KB
testcase_10 AC 519 ms
43,964 KB
testcase_11 AC 463 ms
43,844 KB
testcase_12 AC 439 ms
44,104 KB
testcase_13 AC 451 ms
44,232 KB
testcase_14 AC 467 ms
43,848 KB
testcase_15 AC 452 ms
43,752 KB
testcase_16 AC 453 ms
43,976 KB
testcase_17 AC 521 ms
44,252 KB
testcase_18 AC 521 ms
44,356 KB
testcase_19 AC 449 ms
44,092 KB
testcase_20 AC 451 ms
44,136 KB
testcase_21 AC 460 ms
44,100 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