結果

問題 No.1201 お菓子配り-4
ユーザー rlangevinrlangevin
提出日時 2023-10-26 23:08:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 711 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 79,964 KB
最終ジャッジ日時 2023-10-26 23:09:01
合計ジャッジ時間 50,345 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 226 ms
75,496 KB
testcase_01 AC 1,974 ms
75,772 KB
testcase_02 AC 2,877 ms
75,860 KB
testcase_03 AC 1,385 ms
75,756 KB
testcase_04 AC 713 ms
75,760 KB
testcase_05 AC 1,655 ms
76,060 KB
testcase_06 AC 302 ms
75,576 KB
testcase_07 AC 811 ms
76,060 KB
testcase_08 AC 2,096 ms
75,848 KB
testcase_09 AC 1,550 ms
75,860 KB
testcase_10 AC 76 ms
76,060 KB
testcase_11 AC 437 ms
75,744 KB
testcase_12 AC 3,207 ms
76,060 KB
testcase_13 AC 143 ms
75,724 KB
testcase_14 AC 100 ms
75,412 KB
testcase_15 AC 2,514 ms
75,848 KB
testcase_16 AC 793 ms
75,752 KB
testcase_17 AC 999 ms
75,760 KB
testcase_18 AC 211 ms
75,728 KB
testcase_19 AC 203 ms
75,740 KB
testcase_20 AC 35 ms
53,600 KB
testcase_21 AC 35 ms
53,600 KB
testcase_22 AC 34 ms
53,600 KB
testcase_23 AC 36 ms
53,600 KB
testcase_24 AC 36 ms
53,600 KB
testcase_25 AC 35 ms
53,600 KB
testcase_26 AC 36 ms
53,600 KB
testcase_27 AC 36 ms
53,600 KB
testcase_28 AC 36 ms
53,600 KB
testcase_29 AC 35 ms
53,600 KB
testcase_30 AC 3,996 ms
76,060 KB
testcase_31 AC 3,996 ms
76,060 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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