結果

問題 No.1252 数字根D
ユーザー 👑 obakyan
提出日時 2022-05-02 10:51:06
言語 Lua
(LuaJit 2.1.1734355927)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 13:24:36
合計ジャッジ時間 956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local q = io.read("*n")
local function solve(d, x)
  local rem = x % (d - 1)
  local div = mfl(x / (d - 1))
  local sum = mfl(d * (d - 1) / 2)
  local ret = 1LL * sum * div
  sum = mfl(rem * (rem + 1) / 2)
  ret = ret + sum
  return ret
end
for iq = 1, q do
  local d, a, b = io.read("*n", "*n", "*n")
  local ret = solve(d, b)
  if 1 < a then
    ret = ret - solve(d, a - 1)
  end
  ret = tostring(ret):gsub("LL", "")
  print(ret)
end
0