結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-19 14:30:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 928 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 9,068 KB
最終ジャッジ日時 2023-09-18 06:36:40
合計ジャッジ時間 6,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 16 ms
7,864 KB
testcase_02 AC 18 ms
7,896 KB
testcase_03 AC 20 ms
7,900 KB
testcase_04 AC 650 ms
9,068 KB
testcase_05 AC 917 ms
8,700 KB
testcase_06 AC 928 ms
8,788 KB
testcase_07 AC 88 ms
8,292 KB
testcase_08 AC 466 ms
8,704 KB
testcase_09 AC 610 ms
8,936 KB
testcase_10 AC 616 ms
8,884 KB
testcase_11 AC 343 ms
8,180 KB
testcase_12 AC 455 ms
8,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
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())
	
	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