結果

問題 No.2300 Substring OR Sum
コンテスト
ユーザー obakyan
提出日時 2023-05-12 22:10:58
言語 Lua
(LuaJit 2.1.1774638290)
コンパイル:
luajit -b _filename_ a.out
実行:
luajit _filename_
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 465 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 276 ms
コンパイル使用メモリ 8,100 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-22 17:40:55
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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