結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-19 14:03:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 78,400 KB
最終ジャッジ日時 2023-09-18 06:35:38
合計ジャッジ時間 3,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,192 KB
testcase_01 AC 74 ms
71,192 KB
testcase_02 AC 80 ms
71,480 KB
testcase_03 AC 83 ms
75,600 KB
testcase_04 AC 217 ms
78,400 KB
testcase_05 AC 283 ms
78,080 KB
testcase_06 AC 263 ms
78,304 KB
testcase_07 AC 104 ms
76,916 KB
testcase_08 AC 181 ms
77,916 KB
testcase_09 AC 207 ms
78,176 KB
testcase_10 AC 207 ms
78,316 KB
testcase_11 AC 161 ms
77,664 KB
testcase_12 AC 184 ms
77,784 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