結果
| 問題 |
No.1201 お菓子配り-4
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2021-07-28 13:07:04 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 813 bytes |
| コンパイル時間 | 131 ms |
| コンパイル使用メモリ | 6,688 KB |
| 実行使用メモリ | 13,888 KB |
| 最終ジャッジ日時 | 2024-09-13 09:16:58 |
| 合計ジャッジ時間 | 31,338 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 TLE * 2 -- * 23 |
ソースコード
local function floorSum(n, m, a, b)
local ans = 0LL
while true do
if m <= a then
local v = a / m
ans = ans + v * n * (n - 1LL) / 2LL
a = a % m
end
if m <= b then
ans = ans + (b / m) * n
b = b % m
end
if a == 0LL then break end
local y = (a * n + b) / m
local z = (a * n + b) % m
n, m, a, b = y, a, m, z
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)
-- print(os.clock())