結果

問題 No.462 6日知らずのコンピュータ
ユーザー 👑 obakyanobakyan
提出日時 2021-06-10 20:13:48
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,562 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-20 06:26:46
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,380 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 1 ms
4,384 KB
testcase_50 AC 1 ms
4,388 KB
testcase_51 AC 1 ms
4,384 KB
testcase_52 AC 1 ms
4,384 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,384 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,384 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 1 ms
4,384 KB
testcase_60 AC 1 ms
4,384 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 1 ms
4,384 KB
testcase_64 AC 1 ms
4,380 KB
testcase_65 AC 1 ms
4,384 KB
testcase_66 AC 1 ms
4,380 KB
testcase_67 AC 1 ms
4,384 KB
testcase_68 AC 2 ms
4,384 KB
testcase_69 AC 1 ms
4,384 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,384 KB
testcase_72 AC 1 ms
4,384 KB
testcase_73 AC 1 ms
4,380 KB
testcase_74 AC 1 ms
4,380 KB
testcase_75 AC 1 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 2 ms
4,380 KB
testcase_78 AC 1 ms
4,380 KB
testcase_79 AC 1 ms
4,380 KB
testcase_80 AC 2 ms
4,380 KB
testcase_81 AC 1 ms
4,380 KB
testcase_82 AC 1 ms
4,384 KB
testcase_83 AC 1 ms
4,380 KB
testcase_84 AC 1 ms
4,384 KB
testcase_85 AC 1 ms
4,380 KB
testcase_86 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 31623
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local n, k = io.read("*n", "*n", "*l")
if k == 0 then
  local v = 1
  for i = 2, n do
    v = bmul(v, i)
  end
  print(v)
  os.exit()
end
local max = 0LL
do
  local mul = 1LL
  for i = 1, n do
    max = max + mul
    mul = mul + mul
  end
end
local s = io.read()
local a = {}
local cmap = {}
for w in s:gmatch("%d+") do
  local z = lltonumber(w)
  local tz = z
  local pop = 0
  while 0LL < tz do
    if tz % 2LL == 1LL then
      pop = pop + 1
    end
    tz = tz / 2LL
  end
  if cmap[pop] then print(0) os.exit() end
  cmap[pop] = true
  if 0LL < z and z < max then
    table.insert(a, {z, pop})
  end
end
if #a == 0 then
  local v = 1
  for i = 2, n do
    v = bmul(v, i)
  end
  print(v)
  os.exit()
end
local ret = 1
do
  local c = a[1][2]
  for i = 2, c do
    ret = bmul(ret, i)
  end
end
do
  local c = a[#a][2]
  for i = 2, n - c do
    ret = bmul(ret, i)
  end
end
for i = 1, #a - 1 do
  local len = a[i + 1][2] - a[i][2]
  for i = 2, len do
    ret = bmul(ret, i)
  end
  local ta, tb = a[i][1], a[i + 1][1]
  for j = 0, 70 do
    if ta % 2 == 1 and tb % 2 == 0 then
      print(0) os.exit()
    end
    ta = ta / 2LL
    tb = tb / 2LL
  end
end
print(ret)
0