結果

問題 No.1201 お菓子配り-4
ユーザー rlangevinrlangevin
提出日時 2023-10-26 23:12:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 661 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 76,196 KB
最終ジャッジ日時 2023-10-26 23:13:04
合計ジャッジ時間 48,794 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
75,444 KB
testcase_01 AC 1,926 ms
75,804 KB
testcase_02 AC 2,736 ms
75,852 KB
testcase_03 AC 1,351 ms
75,744 KB
testcase_04 AC 702 ms
75,740 KB
testcase_05 AC 1,627 ms
75,840 KB
testcase_06 AC 290 ms
75,416 KB
testcase_07 AC 790 ms
75,832 KB
testcase_08 AC 2,051 ms
75,840 KB
testcase_09 AC 1,524 ms
75,836 KB
testcase_10 AC 69 ms
74,220 KB
testcase_11 AC 428 ms
75,728 KB
testcase_12 AC 3,102 ms
75,884 KB
testcase_13 AC 161 ms
75,716 KB
testcase_14 AC 96 ms
75,420 KB
testcase_15 AC 2,435 ms
75,852 KB
testcase_16 AC 795 ms
75,744 KB
testcase_17 AC 1,004 ms
75,744 KB
testcase_18 AC 206 ms
75,732 KB
testcase_19 AC 201 ms
75,716 KB
testcase_20 AC 36 ms
53,648 KB
testcase_21 AC 36 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 38 ms
53,648 KB
testcase_26 AC 43 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,920 ms
76,172 KB
testcase_31 AC 3,949 ms
76,196 KB
testcase_32 AC 3,936 ms
76,164 KB
testcase_33 AC 3,933 ms
76,152 KB
testcase_34 AC 3,949 ms
76,148 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):
    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, 0) * 2
    ans %= mod
        
print(ans)
0