結果

問題 No.1966 Median of Divisors
ユーザー ShirotsumeShirotsume
提出日時 2022-01-19 15:33:22
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 81,652 KB
最終ジャッジ日時 2023-09-18 06:36:15
合計ジャッジ時間 5,095 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,308 KB
testcase_01 AC 75 ms
71,400 KB
testcase_02 AC 89 ms
75,608 KB
testcase_03 AC 96 ms
76,312 KB
testcase_04 AC 415 ms
81,580 KB
testcase_05 AC 478 ms
81,204 KB
testcase_06 AC 446 ms
81,508 KB
testcase_07 AC 153 ms
77,724 KB
testcase_08 AC 332 ms
80,292 KB
testcase_09 AC 399 ms
81,456 KB
testcase_10 AC 403 ms
81,652 KB
testcase_11 AC 244 ms
79,128 KB
testcase_12 AC 282 ms
79,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    mod = 10 ** 9 + 7
    n, m = map(int,input().split())
    x = pow(n, m, mod)
    y = pow(n, m // 2, mod)
    ans = x * (x + 1) * pow(2, mod - 2, mod) - y * (2 * y + 1) * (y + 1) * pow(6, mod - 2, mod)
    ans %= mod
    return ans

t = int(input())
ans = []
for _ in range(t):
    ans.append(solve())

for i in ans:
    print(i)
0