結果

問題 No.2300 Substring OR Sum
ユーザー 👑 obakyan
提出日時 2023-05-12 22:10:58
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-28 18:36:59
合計ジャッジ時間 2,126 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local ans = 0LL
local mul = 1LL
local tot = mfl(n * (n + 1) / 2)
for i = 0, 27 do
  local len = 0
  local z = tot
  for j = 1, n do
    if a[j] % 2 == 0 then
      len = len + 1
    else
      len = 0
    end
    a[j] = mfl(a[j] / 2)
    z = z - len
  end
  ans = ans + mul * z
  mul = mul * 2LL
end
ans = tostring(ans):gsub("LL", "")
print(ans)
0