結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー 👑 obakyan
提出日時 2024-08-15 21:02:43
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-08-15 21:02:45
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end
local q = io.read()
q = tonumber(q)
for iq = 1, q do
  local n, x = io.read():match("(%d+) (%d+)")
  n = tonumber(n)
  x = lltonumber(x)
  local min = mfl(n * (n + 1) / 2)
  min = 1LL * min
  if x < min then
    print(-1)
  else
    local t = {}
    for i = 1, n - 1 do
      t[i] = i
      x = x - 1LL * i
    end
    x = tostring(x):gsub("LL", "")
    t[n] = x
    print(table.concat(t, " "))
  end
end
0