結果

問題 No.1966 Median of Divisors
ユーザー roarisroaris
提出日時 2022-06-03 22:38:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 81,640 KB
実行使用メモリ 76,604 KB
最終ジャッジ日時 2023-10-21 02:09:14
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,356 KB
testcase_01 AC 42 ms
53,356 KB
testcase_02 AC 50 ms
57,452 KB
testcase_03 AC 56 ms
63,328 KB
testcase_04 AC 377 ms
76,576 KB
testcase_05 AC 430 ms
76,232 KB
testcase_06 AC 407 ms
76,288 KB
testcase_07 AC 119 ms
76,312 KB
testcase_08 AC 293 ms
76,520 KB
testcase_09 AC 360 ms
76,536 KB
testcase_10 AC 364 ms
76,604 KB
testcase_11 AC 197 ms
76,160 KB
testcase_12 AC 239 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

MOD = 10**9+7
inv = lambda x: pow(x, MOD-2, MOD)

for _ in range(int(input())):
    N, M = map(int, input().split())
    x = pow(N, M, MOD)
    y = pow(N, M//2, MOD)
    print((x*(1+x)*inv(2)%MOD-y*(y+1)*(2*y+1)*inv(6)%MOD)%MOD)
0