結果

問題 No.1966 Median of Divisors
ユーザー hiro1729
提出日時 2024-02-23 09:02:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 417 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-09-29 04:55:59
合計ジャッジ時間 4,422 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9 + 7
for _ in range(int(input())):
	N, M = map(int, input().split())
	ans = 0
	pNM = pow(N, M, mod)
	pNM2 = pow(N, M // 2, mod)
	ans += pNM * (pNM + 1) // 2 % mod
	ans -= pNM2 * (pNM2 + 1) * (2 * pNM2 + 1) // 6 % mod
	ans %= mod
	print(ans)
0