結果

問題 No.1573 Divisor Function
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-14 14:49:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,228 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 86,268 KB
最終ジャッジ日時 2023-10-18 11:40:44
合計ジャッジ時間 5,082 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
68,064 KB
testcase_01 AC 60 ms
68,064 KB
testcase_02 AC 92 ms
86,260 KB
testcase_03 AC 61 ms
68,064 KB
testcase_04 AC 60 ms
68,064 KB
testcase_05 AC 61 ms
68,064 KB
testcase_06 AC 61 ms
68,064 KB
testcase_07 AC 61 ms
68,064 KB
testcase_08 AC 63 ms
68,064 KB
testcase_09 AC 62 ms
68,064 KB
testcase_10 AC 62 ms
68,064 KB
testcase_11 AC 62 ms
68,064 KB
testcase_12 AC 62 ms
68,064 KB
testcase_13 AC 62 ms
68,064 KB
testcase_14 AC 62 ms
68,064 KB
testcase_15 AC 62 ms
68,064 KB
testcase_16 AC 62 ms
68,064 KB
testcase_17 AC 61 ms
68,064 KB
testcase_18 AC 91 ms
85,960 KB
testcase_19 AC 93 ms
86,260 KB
testcase_20 AC 75 ms
75,716 KB
testcase_21 AC 93 ms
86,252 KB
testcase_22 AC 94 ms
85,520 KB
testcase_23 AC 74 ms
76,544 KB
testcase_24 AC 90 ms
84,932 KB
testcase_25 AC 93 ms
86,260 KB
testcase_26 AC 92 ms
85,768 KB
testcase_27 AC 79 ms
76,504 KB
testcase_28 AC 74 ms
75,728 KB
testcase_29 AC 94 ms
86,064 KB
testcase_30 AC 91 ms
85,688 KB
testcase_31 AC 76 ms
76,516 KB
testcase_32 AC 92 ms
86,012 KB
testcase_33 AC 94 ms
86,252 KB
testcase_34 AC 71 ms
73,280 KB
testcase_35 AC 73 ms
75,676 KB
testcase_36 AC 70 ms
72,952 KB
testcase_37 AC 94 ms
86,260 KB
testcase_38 AC 93 ms
86,252 KB
testcase_39 AC 95 ms
86,268 KB
testcase_40 AC 95 ms
86,264 KB
testcase_41 AC 94 ms
86,260 KB
testcase_42 AC 93 ms
86,268 KB
testcase_43 AC 94 ms
86,260 KB
testcase_44 AC 94 ms
86,260 KB
testcase_45 AC 94 ms
86,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


from typing import List, Tuple


def floorRange(n: int) -> List[Tuple[int, int, int]]:
    """
    将 [1,n] 内的数分成O(2*sqrt(n))段, 每段内的 n//i 相同

    Args:
        n (int): n>=1

    Returns:
        List[Tuple[int,int,int]]:
        每个元素为(left,right,div)
        表示 left <= i <= right 内的 n//i == div
    """
    res = []
    m = 1
    while m * m <= n:
        res.append((m, m, n // m))
        m += 1
    for i in range(m, 0, -1):
        left = n // (i + 1) + 1
        right = n // i
        if left <= right and res and res[-1][1] < left:
            res.append((left, right, n // left))
    return res


if __name__ == "__main__":
    # n = int(input())
    # print(floorRange(n))
    # [(1, 2, 9), (2, 3, 4), (3, 4, 3), (5, 10, 1)]

    # https://yukicoder.me/problems/no/1573
    # 约数总和
    MOD = 998244353
    n, m = map(int, input().split())
    res = 0
    for left, right, div in floorRange(n):
        right += 1
        lower = left
        higher = min(right - 1, m)
        if lower > higher:
            break
        x = div * (div + 1) // 2 + div
        y = (lower + higher) * (higher - lower + 1) // 2
        res += x * y
        res %= MOD
    print(res)
0