結果

問題 No.1966 Median of Divisors
ユーザー shobonvipshobonvip
提出日時 2022-06-03 21:30:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 76,924 KB
最終ジャッジ日時 2023-10-21 01:38:53
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,248 KB
testcase_01 AC 37 ms
53,248 KB
testcase_02 AC 54 ms
60,824 KB
testcase_03 AC 64 ms
65,648 KB
testcase_04 AC 407 ms
75,812 KB
testcase_05 AC 473 ms
75,724 KB
testcase_06 AC 431 ms
76,924 KB
testcase_07 AC 125 ms
75,772 KB
testcase_08 AC 318 ms
75,812 KB
testcase_09 AC 389 ms
75,940 KB
testcase_10 AC 391 ms
75,812 KB
testcase_11 AC 227 ms
75,720 KB
testcase_12 AC 263 ms
75,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9 + 7
inv2 = pow(2, mod-2, mod)
inv6 = pow(6, mod-2, mod)
T = int(input())
for _ in range(T):
	n, m = map(int,input().split())
	# 1 -> n^m のうち, 平方数を除いたものの, 総和!!
	v = pow(n, m, mod)
	w = pow(n, m//2, mod)
	print((v*(v+1)*inv2 - w*(w+1)*(2*w+1)*inv6) % mod)
0