結果

問題 No.147 試験監督(2)
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-09-08 08:47:35
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 77,888 KB
実行使用メモリ 80,760 KB
最終ジャッジ日時 2023-09-26 10:05:13
合計ジャッジ時間 2,640 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 356 ms
80,680 KB
testcase_01 AC 355 ms
80,612 KB
testcase_02 AC 357 ms
80,760 KB
testcase_03 AC 74 ms
76,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
mod = int(1e9) + 7

def matmul(A, B):
    res = [[0, 0], [0, 0]]
    res[0][0] = (A[0][0]*B[0][0] + A[0][1]*B[1][0]) % mod
    res[0][1] = (A[0][0]*B[0][1] + A[0][1]*B[1][1]) % mod
    res[1][0] = (A[1][0]*B[0][0] + A[1][1]*B[1][0]) % mod
    res[1][1] = (A[1][0]*B[0][1] + A[1][1]*B[1][1]) % mod
    return res

def matpow(A, n):
    res = [[1, 0], [0, 1]]
    while n > 0:
        if n & 1:
            res = matmul(res, A)
        A = matmul(A, A)
        n >>= 1
    return res

n = int(raw_input())
res = 1
for i in xrange(n):
    c, d = map(int, raw_input().split())
    x = matpow([[1, 1], [1, 0]], c+1)[0][0]
    if d > mod - 1:
        d %= (mod - 1)
    res = res * pow(x, d, mod) % mod
print res
0