結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,836 KB
testcase_01 AC 19 ms
8,836 KB
testcase_02 AC 22 ms
8,740 KB
testcase_03 AC 24 ms
8,828 KB
testcase_04 AC 669 ms
9,632 KB
testcase_05 AC 940 ms
9,576 KB
testcase_06 AC 920 ms
9,752 KB
testcase_07 AC 93 ms
9,104 KB
testcase_08 AC 483 ms
9,360 KB
testcase_09 AC 626 ms
9,544 KB
testcase_10 AC 633 ms
9,704 KB
testcase_11 AC 351 ms
9,184 KB
testcase_12 AC 465 ms
9,168 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