結果

問題 No.1201 お菓子配り-4
ユーザー rlangevinrlangevin
提出日時 2023-10-26 23:05:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 665 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 75,984 KB
最終ジャッジ日時 2023-10-26 23:06:28
合計ジャッジ時間 48,960 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 195 ms
75,452 KB
testcase_01 AC 1,947 ms
75,760 KB
testcase_02 AC 2,723 ms
75,860 KB
testcase_03 AC 1,355 ms
75,748 KB
testcase_04 AC 675 ms
75,744 KB
testcase_05 AC 1,625 ms
75,840 KB
testcase_06 AC 291 ms
75,432 KB
testcase_07 AC 760 ms
75,840 KB
testcase_08 AC 2,066 ms
75,852 KB
testcase_09 AC 1,525 ms
75,840 KB
testcase_10 AC 74 ms
75,804 KB
testcase_11 AC 429 ms
75,732 KB
testcase_12 AC 3,081 ms
75,984 KB
testcase_13 AC 138 ms
75,720 KB
testcase_14 AC 97 ms
75,432 KB
testcase_15 AC 2,457 ms
75,856 KB
testcase_16 AC 771 ms
75,748 KB
testcase_17 AC 986 ms
75,748 KB
testcase_18 AC 206 ms
75,736 KB
testcase_19 AC 198 ms
75,720 KB
testcase_20 AC 36 ms
53,648 KB
testcase_21 AC 35 ms
53,648 KB
testcase_22 AC 36 ms
53,648 KB
testcase_23 AC 36 ms
53,648 KB
testcase_24 AC 36 ms
53,648 KB
testcase_25 AC 36 ms
53,648 KB
testcase_26 AC 37 ms
53,648 KB
testcase_27 AC 36 ms
53,648 KB
testcase_28 AC 36 ms
53,648 KB
testcase_29 AC 36 ms
53,648 KB
testcase_30 AC 3,895 ms
75,888 KB
testcase_31 AC 3,921 ms
75,904 KB
testcase_32 AC 3,916 ms
75,884 KB
testcase_33 AC 3,921 ms
75,888 KB
testcase_34 AC 3,901 ms
75,892 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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