結果

問題 No.1966 Median of Divisors
ユーザー tktk_snsntktk_snsn
提出日時 2022-06-03 22:52:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 441 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 75,836 KB
最終ジャッジ日時 2023-10-21 02:14:15
合計ジャッジ時間 4,872 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,356 KB
testcase_01 AC 39 ms
53,356 KB
testcase_02 AC 57 ms
60,940 KB
testcase_03 AC 66 ms
65,760 KB
testcase_04 AC 384 ms
75,828 KB
testcase_05 AC 441 ms
75,832 KB
testcase_06 AC 439 ms
75,832 KB
testcase_07 AC 116 ms
75,832 KB
testcase_08 AC 292 ms
75,836 KB
testcase_09 AC 360 ms
75,832 KB
testcase_10 AC 363 ms
75,828 KB
testcase_11 AC 212 ms
75,836 KB
testcase_12 AC 255 ms
75,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
div2 = pow(2, mod-2, mod)
div6 = pow(6, mod-2, mod)


def main():
    N, M = map(int, input().split())
    m = M // 2

    x = pow(N, M, mod)
    y = pow(N, m, mod)

    res = x * (x + 1) % mod * div2 % mod
    res -= y * (y + 1) % mod * (2 * y + 1) % mod * div6 % mod
    return res % mod


T = int(input())
for _ in range(T):
    print(main())
0