結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-06-03 20:35:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 76,452 KB
最終ジャッジ日時 2023-10-21 01:35:22
合計ジャッジ時間 4,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,372 KB
testcase_01 AC 38 ms
53,372 KB
testcase_02 AC 44 ms
55,420 KB
testcase_03 AC 49 ms
60,948 KB
testcase_04 AC 188 ms
76,452 KB
testcase_05 AC 255 ms
76,444 KB
testcase_06 AC 235 ms
76,360 KB
testcase_07 AC 75 ms
72,584 KB
testcase_08 AC 149 ms
76,208 KB
testcase_09 AC 178 ms
76,412 KB
testcase_10 AC 176 ms
76,416 KB
testcase_11 AC 128 ms
75,856 KB
testcase_12 AC 151 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 10 ** 9 + 7
inv2 = pow(2, mod - 2, mod)
inv6 = pow(6, mod - 2, mod)

for _ in [0] * int(input()):
    n, m = map(int, input().split())
    h = m // 2
    a = pow(n, m, mod)
    b = pow(n, h, mod)
    ans = a * (a + 1) % mod * inv2 % mod + mod - b * (b + 1) % mod * (2 * b + 1) % mod * inv6 % mod
    ans %= mod
    print(ans)
    
0