結果

問題 No.1201 お菓子配り-4
ユーザー 👑 obakyanobakyan
提出日時 2021-07-28 12:57:21
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 851 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 5,156 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-11 09:58:42
合計ジャッジ時間 10,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 284 ms
7,156 KB
testcase_01 AC 3,881 ms
4,352 KB
testcase_02 TLE -
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 #

local function floorSum(n, m, a, b)
  local ans = 0LL
  while true do
    if m <= a then
      ans = ans + ((n - 1LL) * n / 2LL) * (a / m)
      a = a % m
    end
    if m <= b then
      ans = ans + n * (b / m)
      b = b % m
    end
    local ymax = (a * n + b) / m
    local xmax = ymax * m - b
    if ymax == 0 then break end
    ans = ans + (n - (xmax + a - 1LL) / a) * ymax
    n, m, a, b = ymax, a, m, (a - xmax % a) % a
  end
  return ans
end

local n, m = io.read("*n", "*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n") * 1LL
end
for i = 1, m do
  b[i] = io.read("*n") * 1LL
end
local mod = 1000000007LL
local ret = 0LL
for i = 1, n do
  for j = 1, m do
    local v = floorSum(b[j] + 1, b[j], a[i], 0LL)
    v = v % mod
    ret = (ret + v) % mod
  end
end
ret = (ret + ret) % mod
ret = tostring(ret):gsub("LL", "")
print(ret)
0