結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 👑 obakyanobakyan
提出日時 2019-04-29 08:38:40
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 16:10:20
合計ジャッジ時間 1,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 16 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.read
local n = ior("*n")
local t = {}

local function getxor(x, y)
  local ret = 0
  local mul = 1
  while(0 < x or 0 < y) do
    if((x % 2) + (y % 2) == 1) then
      ret = ret + mul
    end
    x, y, mul = math.floor(x / 2), math.floor(y / 2), mul * 2
  end
  return ret
end

for i = 1, n do
  local a = ior("*n")
  if(t[a] == nil) then
    local tmp = {}
    for k, v in pairs(t) do
      table.insert(tmp, getxor(k, a))
    end
    for j = 1, #tmp do
      t[tmp[j]] = true
    end
    t[a] = true
  end
end
local cnt = 0
for k, v in pairs(t) do
  cnt = cnt + 1
end
print(cnt + 1)
0