結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-17 18:30:31
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 79,600 KB
最終ジャッジ日時 2023-09-18 06:35:12
合計ジャッジ時間 3,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
72,160 KB
testcase_01 AC 95 ms
72,172 KB
testcase_02 AC 96 ms
72,284 KB
testcase_03 AC 104 ms
77,192 KB
testcase_04 AC 233 ms
79,424 KB
testcase_05 AC 299 ms
79,600 KB
testcase_06 AC 280 ms
79,516 KB
testcase_07 AC 128 ms
78,412 KB
testcase_08 AC 199 ms
79,024 KB
testcase_09 AC 229 ms
79,356 KB
testcase_10 AC 228 ms
79,332 KB
testcase_11 AC 180 ms
79,012 KB
testcase_12 AC 203 ms
79,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = sys.stdin.readline
mod = 10 ** 9 + 7
rev2 = pow(2, mod - 2, mod)
rev6 = pow(6, mod - 2, mod)

for _ in [0] * int(input()):
	n, m = map(int, input().split());	n %= mod
	
	a = pow(n, m, mod)
	b = pow(n, m // 2, mod)

	s = rev2 * a % mod * (a + 1) % mod
	t = rev6 * b % mod * (b + 1) % mod * (b * 2 + 1) % mod

	ans = (s + mod - t) % mod
	print(ans)
0