結果

問題 No.147 試験監督(2)
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-04 17:42:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,154 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 78,944 KB
最終ジャッジ日時 2023-09-25 01:05:41
合計ジャッジ時間 5,752 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,150 ms
78,932 KB
testcase_01 AC 1,154 ms
78,932 KB
testcase_02 AC 1,152 ms
78,944 KB
testcase_03 AC 72 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(c, d, mod):
    return pow(g(c, mod), d, mod)

def g(c, mod):
    p, q = 1, 1
    a, b = 2, 1
    while c:
        if c & 1:
            tmp = p - q
            p = (a*q + b*tmp) % mod
            q = (a*tmp - b*(tmp - q)) % mod
        t = a - b
        t *= t
        a *= a
        a -= t
        a %= mod
        b *= b
        b += t
        b %= mod
        c >>= 1
    return p

def solve():
    mod = 10**9 + 7
    N = int(input())
    ans = 1
    for n in range(N):
        c, d = map(int, input().split())
        ans *= f(c, d, mod)
        ans %= mod
    return ans

print(solve())
0