結果
問題 | No.1742 Binary Indexed Train |
ユーザー |
👑 |
提出日時 | 2022-01-16 20:37:13 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 1,415 ms / 3,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 12:20:21 |
合計ジャッジ時間 | 22,299 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
local function mmi(a, b) return a < b and a or b endlocal ffi = require("ffi")local C = ffi.Cffi.cdef[[long long atoll(const char*);]]local function lltonumber(str)return C.atoll(str)endlocal n, q = io.read("*n", "*n", "*l")local lim = 1LLfor i = 1, n dolim = lim + limendfor iq = 1, q dolocal s, t = io.read():match("(%d+) (%d+)")s = lltonumber(s)t = lltonumber(t)local z = 0local len = t - slocal j1 = 1LLwhile s % (j1 + j1) == 0LL and j1 + j1 <= lim doj1 = j1 + j1endlocal j2 = 1LLwhile j2 + j2 <= len and j2 + j2 <= lim doj2 = j2 + j2endlocal j = mmi(j1, j2)s = s + jlen = len - jwhile 0LL < len dowhile s % (2LL * j1) == 0LL and j1 + j1 <= lim doj1 = j1 + j1-- print("a", j1, s)endwhile s % j1 == 1LL doj1 = j1 / 2LL-- print("C", j1, s)-- print(j1, s)endwhile len < j2 doj2 = j2 / 2LL-- print("B", j2, len)end-- print(j1, j2)j = mmi(j1, j2)z = z + 1len = len - js = s + jendprint(z + 1)end-- print(os.clock())