結果

問題 No.1810 RGB Biscuits
ユーザー ああいいああいい
提出日時 2022-01-14 21:57:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 79,524 KB
最終ジャッジ日時 2023-08-12 19:28:58
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,216 KB
testcase_01 AC 75 ms
75,956 KB
testcase_02 AC 71 ms
76,012 KB
testcase_03 AC 80 ms
76,036 KB
testcase_04 AC 82 ms
76,324 KB
testcase_05 AC 186 ms
78,220 KB
testcase_06 AC 210 ms
78,976 KB
testcase_07 AC 222 ms
78,972 KB
testcase_08 AC 212 ms
79,524 KB
testcase_09 AC 194 ms
78,204 KB
testcase_10 AC 174 ms
78,132 KB
testcase_11 AC 87 ms
76,088 KB
testcase_12 AC 99 ms
77,396 KB
testcase_13 AC 83 ms
76,072 KB
testcase_14 AC 126 ms
78,036 KB
testcase_15 AC 97 ms
77,556 KB
testcase_16 AC 111 ms
77,804 KB
testcase_17 AC 157 ms
79,268 KB
testcase_18 AC 164 ms
78,696 KB
testcase_19 AC 82 ms
76,388 KB
testcase_20 AC 73 ms
76,220 KB
testcase_21 AC 113 ms
78,052 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