結果

問題 No.1201 お菓子配り-4
ユーザー rlangevinrlangevin
提出日時 2023-10-26 23:16:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 666 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 75,836 KB
最終ジャッジ日時 2023-10-26 23:17:10
合計ジャッジ時間 49,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
75,392 KB
testcase_01 AC 1,910 ms
75,704 KB
testcase_02 AC 2,708 ms
75,804 KB
testcase_03 AC 1,345 ms
75,696 KB
testcase_04 AC 677 ms
75,692 KB
testcase_05 AC 1,625 ms
75,784 KB
testcase_06 AC 316 ms
75,376 KB
testcase_07 AC 760 ms
75,780 KB
testcase_08 AC 2,055 ms
75,788 KB
testcase_09 AC 1,523 ms
75,780 KB
testcase_10 AC 68 ms
74,068 KB
testcase_11 AC 428 ms
75,680 KB
testcase_12 AC 3,110 ms
75,832 KB
testcase_13 AC 137 ms
75,664 KB
testcase_14 AC 96 ms
75,368 KB
testcase_15 AC 2,454 ms
75,796 KB
testcase_16 AC 774 ms
75,716 KB
testcase_17 AC 992 ms
75,696 KB
testcase_18 AC 204 ms
75,684 KB
testcase_19 AC 198 ms
75,668 KB
testcase_20 AC 36 ms
53,600 KB
testcase_21 AC 36 ms
53,600 KB
testcase_22 AC 37 ms
53,600 KB
testcase_23 AC 36 ms
53,600 KB
testcase_24 AC 36 ms
53,600 KB
testcase_25 AC 37 ms
53,600 KB
testcase_26 AC 37 ms
53,600 KB
testcase_27 AC 36 ms
53,600 KB
testcase_28 AC 37 ms
53,600 KB
testcase_29 AC 36 ms
53,600 KB
testcase_30 AC 3,907 ms
75,832 KB
testcase_31 AC 3,918 ms
75,836 KB
testcase_32 AC 3,911 ms
75,812 KB
testcase_33 AC 3,921 ms
75,832 KB
testcase_34 AC 3,912 ms
75,836 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://qiita.com/AkariLuminous/items/3e2c80baa6d5e6f3abe9#4-floor_sum
mod = 10**9 + 7
def floor_sum(n, m, a, b=0):
    ans = 0
    while True:
        if a >= m or a < 0:
            ans += n * (n - 1) * (a // m) // 2
            a %= m
        if b >= m or b < 0:
            ans += n * (b // m)
            b %= m
        y_max = a * n + b
        if y_max < m: break
        n, b, m, a = y_max // m, y_max % m, a, m
    return ans   

N = int(input())
M = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for a in A:
    for b in B:
        ans += floor_sum(b + 1, b, a)
    ans %= mod
        
print(ans * 2 % mod)
0