結果

問題 No.1573 Divisor Function
ユーザー sushitoruna
提出日時 2021-06-18 21:55:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-25 11:16:42
合計ジャッジ時間 6,467 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# 解法 Σ[j=1→m]j×(n/j)×(n/j+3)/2 n/jの値で場合分け
n,m=map(int,input().split())
ans=0
mod=998244353
j_sum=0
def clac(x):
  # j_sum=n//jがxとなるjの和
  j_sum=(min(m+1,n//(x+1)+1)+min(m,n//x))*(min(m,n//x)-min(m,n//(x+1)))*499122177
  j_sum%=mod
  res=j_sum*x*(x+3)*499122177				
  res%=mod
  return res
for x in range(1,int(n**.5)+1):
  # n//j=xの場合
  ans+=clac(x)
  ans%=mod
  # n//j=n//xの場合
  if n//x!=x :
    ans+=clac(n//x)
    ans%=mod
print(ans)
0