結果

問題 No.1966 Median of Divisors
ユーザー Eguy
提出日時 2022-06-03 22:11:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 296 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 84,840 KB
最終ジャッジ日時 2024-09-21 02:47:25
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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