結果

問題 No.147 試験監督(2)
コンテスト
ユーザー rpy3cpp
提出日時 2015-08-08 21:07:48
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 781 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 546 ms
コンパイル使用メモリ 81,180 KB
実行使用メモリ 167,380 KB
最終ジャッジ日時 2026-04-01 22:20:30
合計ジャッジ時間 5,821 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def g(c, mod, memo):
    p, q = 1, 1
    i = 0
    while c:
        if c & 1:
            a, b = memo[i]
            tmp = p - q
            p = (a*q + b*tmp) % mod
            q = (a*tmp - b*(tmp - q)) % mod
        c >>= 1
        i += 1
    return p

def preprocess(c, mod):
    a, b = 2, 1
    memo = [(2, 1)]
    while c:
        t = a - b
        t *= t
        a *= a
        a -= t
        a %= mod
        b *= b
        b += t
        b %= mod
        c >>= 1
        memo.append((a, b))
    return memo

def solve():
    mod = 10**9 + 7
    memo = preprocess(10**18, mod)
    N = int(raw_input())
    ans = 1
    for n in range(N):
        c, d = map(int, raw_input().split())
        ans *= pow(g(c, mod, memo), d, mod)
        ans %= mod
    return ans

print(solve())
0