結果

問題 No.752 mod数列
ユーザー KTR216KTR216
提出日時 2018-11-09 23:29:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2023-08-13 12:11:12
合計ジャッジ時間 4,580 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,140 KB
testcase_01 AC 17 ms
7,780 KB
testcase_02 WA -
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 15 ms
7,940 KB
testcase_05 AC 17 ms
7,836 KB
testcase_06 AC 16 ms
7,888 KB
testcase_07 AC 18 ms
7,848 KB
testcase_08 AC 17 ms
7,828 KB
testcase_09 AC 17 ms
7,780 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(p, r):
    ans = 0
    if r * r < p:
        for i in range(1, r + 1):
            ans = ans + p % i
        return ans
    if r > p:
        ans = (r - p) * p
    i = int(p / r)
    if i == 0:
        i = 1
        r = p
    s = p % r
    n = r - int(p / (i + 1))
    ans = ans + int((2 * s + i * (n - 1)) * n / 2)
    i = i + 1
    while i * i <= p:
        s = p % int(p / i)
        n = int(p / i) - int(p/ (i + 1))
        ans = ans + int((2 * s + i * (n - 1)) * n / 2)
        i = i + 1
    for i in range(1, p):
        if i * i >= p:
            break
        ans = ans + p % i
    return ans

P, Q = map(int, input().split())
for i in range(Q):
    L, R = map(int, input().split())
    print(solve(P, R) - solve(P, L - 1))
0