結果

問題 No.1201 お菓子配り-4
ユーザー mkawa2mkawa2
提出日時 2021-07-06 01:14:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,243 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 12,916 KB
最終ジャッジ日時 2023-09-14 04:18:52
合計ジャッジ時間 9,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,695 ms
8,160 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

# sum((a*i+b)//m for i in range(n))が求まる
# a,b>=0 m>=1

def floor_sum(n: int, m: int, a: int, b: int) -> int:
    ans = 0
    while 1:
        if a >= m:
            ans += (n-1)*n*(a//m)//2
            a %= m
        if b >= m:
            ans += n*(b//m)
            b %= m
        y_max = (a*n+b)//m
        x_max = y_max*m-b
        if y_max == 0: return ans
        ans += (n-(x_max+a-1)//a)*y_max%md
        ans %= md
        n, m, a, b = y_max, a, m, (a-x_max%a)%a

n = II()
m = II()
aa = LI()
bb = LI()

ans = 0
for a in aa:
    for b in bb:
        ans += 2*floor_sum(b+1, b, a, 0)
        ans %= md
print(ans)
0