結果

問題 No.1966 Median of Divisors
ユーザー 👑 rin204rin204
提出日時 2022-06-03 21:49:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 279 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 75,680 KB
最終ジャッジ日時 2023-10-21 01:47:40
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,204 KB
testcase_01 AC 38 ms
53,204 KB
testcase_02 AC 54 ms
60,768 KB
testcase_03 AC 62 ms
65,592 KB
testcase_04 AC 400 ms
75,680 KB
testcase_05 AC 474 ms
75,656 KB
testcase_06 AC 451 ms
75,648 KB
testcase_07 AC 125 ms
75,668 KB
testcase_08 AC 320 ms
75,680 KB
testcase_09 AC 395 ms
75,680 KB
testcase_10 AC 392 ms
75,680 KB
testcase_11 AC 222 ms
75,648 KB
testcase_12 AC 275 ms
75,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
平方数以外
"""


MOD = 10 ** 9 + 7

def solve():
    n, m = map(int, input().split())
    x = pow(n, m, MOD)
    ans = x * (x + 1) // 2
    x = pow(n, m // 2, MOD)
    ans -= x * (x + 1) * (2 * x + 1) // 6
    print(ans % MOD)


for _ in range(int(input())):
    solve()
0