結果
問題 | No.1651 Removing Cards |
ユーザー |
👑 |
提出日時 | 2024-11-07 21:28:50 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,237 bytes |
コンパイル時間 | 298 ms |
コンパイル使用メモリ | 5,632 KB |
実行使用メモリ | 38,584 KB |
最終ジャッジ日時 | 2024-11-07 21:29:35 |
合計ジャッジ時間 | 29,859 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 32 |
ソースコード
local ffi = require("ffi")local C = ffi.Cffi.cdef[[long long atoll(const char*);]]local function lltonumber(str)return C.atoll(str)endlocal k, q = io.read("*n", "*n", "*l")k = 1LL * klocal lim = 1000000007LL * 1000000007LLlocal function solve(x)local min, max = x - 1LL, x * 2LL + 10while 1LL < max - min dolocal mid = (min + max) / 2LLlocal v = (mid + k - 1LL) / kif x + 1LL <= mid - v thenmax = midelsemin = midendendreturn max - 1LLendlocal t = {}local sz = 1LLwhile sz < lim dosz = solve(sz)table.insert(t, sz)end-- print(t[1])-- print(#t, t[#t])-- os.exit()local a = {}local aidx = {}local ans = {}for iq = 1, q doaidx[iq] = iqlocal z = io.read()z = string.rep("0", 19 - #z) .. za[iq] = zans[iq] = 0endtable.sort(aidx, function(x, y) return a[x] < a[y] end)print("!") os.exit()local tpos = 1for iq = 1, q dolocal i = aidx[iq]local n = lltonumber(a[i])if n == 1LL thenans[i] = 1elsewhile tpos <= #t and t[tpos] < n dotpos = tpos + 1endif tpos == 1 thenans[i] = 2elseans[i] = tostring(t[tpos - 1] + 1LL):gsub("LL", "")endendendprint(table.concat(ans, "\n"))