結果
| 問題 |
No.2880 Max Sigma Mod
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 08:39:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,206 ms / 3,000 ms |
| コード長 | 561 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 82,420 KB |
| 実行使用メモリ | 76,104 KB |
| 最終ジャッジ日時 | 2024-08-02 08:40:15 |
| 合計ジャッジ時間 | 19,559 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
# 入力を受け取る
N, M = map(int, input().split())
# 「増加分」の計算 O(√x)
def calc(x : int):
res = M
i = 1
while i * i <= x:
if x % i == 0:
if i <= M: res -= i
# i * i == x の時は i == x / i なので重複してしまう
if i * i != x and x // i <= M: res -= x // i
i += 1
return res
# 1 <= x <= N を満たすxについて sum(x mod i) の最大値を計算
res = 0
modsum = 0
for x in range(1, N + 1):
modsum += calc(x)
res = max(res, modsum)
print(res)