結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-18 23:52:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 838 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 8,848 KB
最終ジャッジ日時 2023-09-18 06:35:18
合計ジャッジ時間 5,748 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,800 KB
testcase_01 AC 16 ms
7,952 KB
testcase_02 AC 18 ms
7,944 KB
testcase_03 AC 19 ms
7,880 KB
testcase_04 AC 553 ms
8,708 KB
testcase_05 AC 838 ms
8,708 KB
testcase_06 AC 814 ms
8,728 KB
testcase_07 AC 77 ms
8,308 KB
testcase_08 AC 400 ms
8,784 KB
testcase_09 AC 524 ms
8,848 KB
testcase_10 AC 527 ms
8,708 KB
testcase_11 AC 311 ms
8,364 KB
testcase_12 AC 409 ms
8,576 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