結果

問題 No.1966 Median of Divisors
ユーザー EguyEguy
提出日時 2022-06-03 22:11:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,564 KB
実行使用メモリ 84,172 KB
最終ジャッジ日時 2023-10-21 01:55:28
合計ジャッジ時間 3,337 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,452 KB
testcase_01 AC 37 ms
53,452 KB
testcase_02 AC 43 ms
60,892 KB
testcase_03 AC 47 ms
63,740 KB
testcase_04 AC 206 ms
84,172 KB
testcase_05 AC 279 ms
83,980 KB
testcase_06 AC 236 ms
82,272 KB
testcase_07 AC 79 ms
75,840 KB
testcase_08 AC 159 ms
81,652 KB
testcase_09 AC 194 ms
83,892 KB
testcase_10 AC 205 ms
83,924 KB
testcase_11 AC 133 ms
78,756 KB
testcase_12 AC 158 ms
79,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
mod = 1000000007
#mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))

def s(n):
    return (1+n)*n //2

def f(n):
    return n*(n+1)*(2*n + 1) //6
t = int(input())


ans = []
for _ in range(t):
    N, M = li()
    x = pow(N, M, mod)
    y = pow(N, M//2, mod)
    ans.append((s(x) - f(y)) % mod)

print(*ans, sep='\n')
0