結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-18 23:53:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2023-09-18 06:35:00
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,272 KB
testcase_01 AC 73 ms
71,432 KB
testcase_02 AC 78 ms
71,436 KB
testcase_03 AC 83 ms
75,656 KB
testcase_04 AC 211 ms
78,336 KB
testcase_05 AC 276 ms
78,284 KB
testcase_06 AC 257 ms
78,016 KB
testcase_07 AC 104 ms
76,892 KB
testcase_08 AC 177 ms
78,280 KB
testcase_09 AC 204 ms
78,488 KB
testcase_10 AC 205 ms
78,396 KB
testcase_11 AC 158 ms
77,840 KB
testcase_12 AC 181 ms
77,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
rev2 = 500000004
rev6 = 166666668

def solve():
	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)

solve()
0