結果

問題 No.1810 RGB Biscuits
ユーザー ああいいああいい
提出日時 2022-01-14 21:57:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 78,308 KB
最終ジャッジ日時 2024-04-30 14:33:52
合計ジャッジ時間 3,298 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,612 KB
testcase_01 AC 48 ms
61,900 KB
testcase_02 AC 44 ms
59,420 KB
testcase_03 AC 56 ms
67,052 KB
testcase_04 AC 57 ms
66,372 KB
testcase_05 AC 171 ms
77,080 KB
testcase_06 AC 203 ms
77,248 KB
testcase_07 AC 227 ms
78,308 KB
testcase_08 AC 199 ms
77,424 KB
testcase_09 AC 182 ms
77,480 KB
testcase_10 AC 162 ms
77,280 KB
testcase_11 AC 61 ms
65,400 KB
testcase_12 AC 75 ms
77,332 KB
testcase_13 AC 60 ms
70,884 KB
testcase_14 AC 106 ms
77,408 KB
testcase_15 AC 74 ms
76,184 KB
testcase_16 AC 88 ms
76,736 KB
testcase_17 AC 138 ms
77,120 KB
testcase_18 AC 150 ms
76,796 KB
testcase_19 AC 58 ms
66,508 KB
testcase_20 AC 46 ms
59,864 KB
testcase_21 AC 95 ms
76,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

R = [[A,B,0],[1,0,0],[0,0,0]]
S = [[1,0,0,],[0,1,0],[A,B,0]]
def seki(X,Y):
    l = [[0] *3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                l[i][j] = (l[i][j] + X[i][k] * Y[k][j]) % P
    return l
for _ in range(N):
    t = int(input())
    q = t // 2
    r = t % 2
    tmp = [[1,0,0,],[0,1,0],[0,0,1]]
    Rnow = R
    while q:
        if q & 1:
            tmp = seki(Rnow,tmp)
        q >>= 1
        Rnow = seki(Rnow,Rnow)
    if r:
        tmp = seki(S,tmp)
    ans = tmp[0][0] + tmp[0][1] + tmp[1][0] + tmp[1][1] + tmp[2][0] + tmp[2][1]
    print(ans % P)
0