結果

問題 No.1966 Median of Divisors
ユーザー 👑 KazunKazun
提出日時 2022-06-03 22:27:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 90,284 KB
最終ジャッジ日時 2023-10-21 02:02:09
合計ジャッジ時間 5,133 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
83,152 KB
testcase_01 AC 106 ms
83,152 KB
testcase_02 AC 131 ms
83,536 KB
testcase_03 AC 126 ms
83,532 KB
testcase_04 AC 289 ms
90,284 KB
testcase_05 AC 323 ms
89,888 KB
testcase_06 AC 308 ms
89,912 KB
testcase_07 AC 140 ms
87,224 KB
testcase_08 AC 215 ms
89,088 KB
testcase_09 AC 242 ms
89,700 KB
testcase_10 AC 247 ms
89,712 KB
testcase_11 AC 196 ms
87,792 KB
testcase_12 AC 219 ms
88,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from tkinter import Y


def prod_mod(*X):
    y=1
    for x in X:
        y*=x; y%=Mod
    return y
#==================================================

import sys
input=sys.stdin.readline
write=sys.stdout.write

T=int(input())

Ans=[0]*T

Mod=10**9+7
two_inv=pow(2,Mod-2,Mod)
six_inv=pow(6,Mod-2,Mod)

for t in range(T):
    N,M=map(int,input().split())

    alpha=pow(N,M,Mod); X=prod_mod(two_inv, alpha, alpha+1)
    beta =pow(N,M//2,Mod); Y=prod_mod(six_inv, beta, beta+1, 2*beta+1)

    Ans[t]=(X-Y)%Mod

write("\n".join(map(str,Ans)))
0