結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-18 23:54:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 936 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,576 KB
実行使用メモリ 9,096 KB
最終ジャッジ日時 2023-09-18 06:35:33
合計ジャッジ時間 6,416 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,732 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 20 ms
7,880 KB
testcase_03 AC 21 ms
7,780 KB
testcase_04 AC 655 ms
9,096 KB
testcase_05 AC 936 ms
8,784 KB
testcase_06 AC 930 ms
8,896 KB
testcase_07 AC 89 ms
8,360 KB
testcase_08 AC 469 ms
8,900 KB
testcase_09 AC 613 ms
9,036 KB
testcase_10 AC 624 ms
9,000 KB
testcase_11 AC 352 ms
8,240 KB
testcase_12 AC 455 ms
8,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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