結果

問題 No.1201 お菓子配り-4
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-11 15:16:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 998 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 76,112 KB
最終ジャッジ日時 2023-10-18 09:57:21
合計ジャッジ時間 51,827 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
75,464 KB
testcase_01 AC 2,019 ms
75,804 KB
testcase_02 AC 2,897 ms
76,044 KB
testcase_03 AC 1,416 ms
75,780 KB
testcase_04 AC 732 ms
75,784 KB
testcase_05 AC 1,717 ms
76,044 KB
testcase_06 AC 323 ms
75,500 KB
testcase_07 AC 826 ms
76,044 KB
testcase_08 AC 2,168 ms
76,044 KB
testcase_09 AC 1,616 ms
76,044 KB
testcase_10 AC 85 ms
76,044 KB
testcase_11 AC 463 ms
75,776 KB
testcase_12 AC 3,234 ms
76,044 KB
testcase_13 AC 152 ms
75,744 KB
testcase_14 AC 106 ms
75,428 KB
testcase_15 AC 2,677 ms
76,044 KB
testcase_16 AC 822 ms
75,780 KB
testcase_17 AC 1,058 ms
75,788 KB
testcase_18 AC 224 ms
75,748 KB
testcase_19 AC 214 ms
75,744 KB
testcase_20 AC 38 ms
53,616 KB
testcase_21 AC 39 ms
53,616 KB
testcase_22 AC 39 ms
53,616 KB
testcase_23 AC 39 ms
53,616 KB
testcase_24 AC 39 ms
53,616 KB
testcase_25 AC 38 ms
53,616 KB
testcase_26 AC 39 ms
53,616 KB
testcase_27 AC 39 ms
53,616 KB
testcase_28 AC 37 ms
53,616 KB
testcase_29 AC 39 ms
53,616 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #


from math import ceil

MOD = int(1e9 + 7)


def floor_sum_of_linear(L: int, R: int, a: int, b: int, div: int) -> int:
    """
    ```
    sum((x * a + b) // div for x in range(L, R))
    ```
    """
    if L >= R:
        return 0
    res = 0
    b += L * a
    n = R - L

    if b < 0:
        k = ceil(-b / div)
        b += k * div
        res -= n * k

    while n:
        q, a = a // div, a % div
        res += n * (n - 1) // 2 * q
        res %= MOD
        if b >= div:
            q, b = b // div, b % div
            res += n * q
            res %= MOD
        n, b = (a * n + b) // div, (a * n + b) % div
        a, div = div, a

    return res


if __name__ == "__main__":
    n = int(input())
    m = int(input())
    nums1 = list(map(int, input().split()))
    nums2 = list(map(int, input().split()))

    res = 0
    for a in nums1:
        for b in nums2:
            res += floor_sum_of_linear(1, b + 1, a, 0, b)
            res %= MOD
    res *= 2
    res %= MOD
    print(res)
0