結果
問題 | No.2880 Max Sigma Mod |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:45:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 659 ms / 3,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 82,272 KB |
実行使用メモリ | 78,104 KB |
最終ジャッジ日時 | 2025-03-20 20:45:42 |
合計ジャッジ時間 | 7,733 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
ソースコード
import math import sys def main(): input = sys.stdin.read().split() N = int(input[0]) M = int(input[1]) max_n = max(N, M) sigma = [0] * (max_n + 2) # Precompute sigma for 1..max_n # Precompute the sum of divisors (σ) using a sieve approach for i in range(1, max_n + 1): for j in range(i, max_n + 1, i): sigma[j] += i sum_prev = 0 max_sum = 0 for x_current in range(1, N + 1): if x_current <= M: delta = sigma[x_current] else: delta = 0 sqrt_x = int(math.isqrt(x_current)) for i in range(1, sqrt_x + 1): if x_current % i == 0: j = x_current // i if i <= M: delta += i if j != i and j <= M: delta += j sum_prev += delta current_sum = x_current * M - sum_prev if current_sum > max_sum: max_sum = current_sum print(max_sum) if __name__ == "__main__": main()