結果

問題 No.1966 Median of Divisors
ユーザー ああいいああいい
提出日時 2022-06-03 21:48:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 481 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 77,032 KB
最終ジャッジ日時 2023-10-21 01:47:12
合計ジャッジ時間 5,099 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,264 KB
testcase_01 AC 39 ms
53,264 KB
testcase_02 AC 55 ms
60,836 KB
testcase_03 AC 63 ms
65,660 KB
testcase_04 AC 409 ms
75,752 KB
testcase_05 AC 481 ms
75,724 KB
testcase_06 AC 456 ms
77,032 KB
testcase_07 AC 124 ms
75,748 KB
testcase_08 AC 313 ms
75,752 KB
testcase_09 AC 383 ms
75,752 KB
testcase_10 AC 389 ms
75,752 KB
testcase_11 AC 225 ms
75,720 KB
testcase_12 AC 278 ms
75,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
P = 10 ** 9 + 7
def calc(n,m):
    N = n
    M = m
    u = pow(N,M,P)
    ans = u * (u + 1) // 2 % P
    v = pow(N,M // 2,P)
    tmp = v * (v + 1) * (2 * v + 1) // 6
    return (ans - tmp) % P
for _ in range(T):
    n,m = map(int,input().split())
    print(calc(n,m))
0