結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー 👑 obakyanobakyan
提出日時 2022-01-22 19:29:52
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,575 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 7,164 KB
実行使用メモリ 11,824 KB
最終ジャッジ日時 2023-08-18 14:15:33
合計ジャッジ時間 3,677 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
11,636 KB
testcase_01 AC 24 ms
11,640 KB
testcase_02 AC 24 ms
11,256 KB
testcase_03 AC 22 ms
11,560 KB
testcase_04 AC 24 ms
11,672 KB
testcase_05 AC 25 ms
11,580 KB
testcase_06 AC 24 ms
11,524 KB
testcase_07 AC 24 ms
11,196 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 26 ms
11,320 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 23 ms
11,536 KB
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 AC 24 ms
11,524 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 24 ms
11,248 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 24 ms
11,556 KB
testcase_37 AC 23 ms
11,568 KB
testcase_38 AC 22 ms
11,524 KB
testcase_39 AC 24 ms
11,564 KB
testcase_40 AC 24 ms
11,672 KB
testcase_41 WA -
testcase_42 AC 22 ms
11,636 KB
testcase_43 AC 23 ms
11,568 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 24 ms
11,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs

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 function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end
local primes = getprimes(1000000)


local function getdivisorparts(x)
  local prime_num = #primes
  local tmp = {}
  local lim = mce(msq(x))
  local primepos = 1
  local dv = primes[primepos]
  while primepos <= prime_num and dv <= lim do
    if x % dv == 0 then
      local cnt = 1
      x = mfl(x / dv)
      while x % dv == 0 do
        x = mfl(x / dv)
        cnt = cnt + 1
      end
      tmp[dv] = cnt
      lim = mce(msq(x))
    end
    if primepos == prime_num then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if x ~= 1 then
    tmp[x] = 1
  end
  return tmp
end

local x, a, y, b = io.read():match("(%d+) (%d+) (%d+) (%d+)")
local function ans(f) print(f and "Yes" or "No") os.exit() end
x = tonumber(x)
y = tonumber(y)
a = lltonumber(a)
b = lltonumber(b)

local xdv = getdivisorparts(x)
local ydv = getdivisorparts(y)

for k, v in pairs(xdv) do
  xdv[k] = b * v
end
for k, v in pairs(ydv) do
  if not xdv[k] then ans(false) end
  if xdv[k] < a * v then ans(false) end
end
ans(true)
0