結果

問題 No.147 試験監督(2)
ユーザー pluto77pluto77
提出日時 2019-11-21 14:06:05
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 605 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 21,304 KB
最終ジャッジ日時 2024-04-18 02:18:34
合計ジャッジ時間 7,753 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki147
import sys

def mul(x, y):
    l=[[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                l[i][j]+=x[i][k]*y[k][j]
            l[i][j]%=mod
    return l

def matpow(n):
    p=[[1, 1], [1, 0]]
    l=[[1, 0], [0, 1]]
    while n>0:
        if n%2:
            l=mul(l, p)
        p=mul(p, p)
        n/=2
    return l

mod=10**9+7
n=int(raw_input())
res=1
for i in range(n):
    c, d=map(int, raw_input().split())
    x=matpow(c+2)[1][0]
    if x==0:
        print 0
        sys.exit()
    res*=pow(x, d%(mod-1), mod)
    res%=mod
print res
0