結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー 👑 obakyanobakyan
提出日時 2022-01-22 19:32:11
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,575 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 7,128 KB
実行使用メモリ 11,684 KB
最終ジャッジ日時 2023-08-18 14:18:33
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
11,528 KB
testcase_01 AC 28 ms
11,556 KB
testcase_02 AC 28 ms
11,200 KB
testcase_03 AC 28 ms
11,588 KB
testcase_04 AC 28 ms
11,652 KB
testcase_05 AC 28 ms
11,656 KB
testcase_06 AC 28 ms
11,592 KB
testcase_07 AC 29 ms
11,300 KB
testcase_08 AC 28 ms
11,324 KB
testcase_09 AC 32 ms
11,304 KB
testcase_10 AC 28 ms
11,324 KB
testcase_11 AC 29 ms
11,252 KB
testcase_12 AC 29 ms
11,508 KB
testcase_13 AC 29 ms
11,260 KB
testcase_14 AC 28 ms
11,300 KB
testcase_15 AC 28 ms
11,604 KB
testcase_16 AC 29 ms
11,316 KB
testcase_17 AC 29 ms
11,628 KB
testcase_18 AC 29 ms
11,268 KB
testcase_19 AC 27 ms
11,552 KB
testcase_20 AC 28 ms
11,208 KB
testcase_21 AC 28 ms
11,216 KB
testcase_22 AC 28 ms
11,584 KB
testcase_23 AC 27 ms
11,556 KB
testcase_24 AC 28 ms
11,272 KB
testcase_25 AC 28 ms
11,216 KB
testcase_26 AC 28 ms
11,344 KB
testcase_27 AC 28 ms
11,208 KB
testcase_28 AC 28 ms
11,268 KB
testcase_29 AC 28 ms
11,568 KB
testcase_30 AC 28 ms
11,676 KB
testcase_31 AC 28 ms
11,204 KB
testcase_32 AC 28 ms
11,228 KB
testcase_33 AC 28 ms
11,272 KB
testcase_34 AC 27 ms
11,272 KB
testcase_35 AC 28 ms
11,572 KB
testcase_36 AC 29 ms
11,572 KB
testcase_37 AC 29 ms
11,528 KB
testcase_38 AC 28 ms
11,648 KB
testcase_39 AC 28 ms
11,528 KB
testcase_40 AC 28 ms
11,556 KB
testcase_41 AC 28 ms
11,588 KB
testcase_42 AC 27 ms
11,584 KB
testcase_43 AC 27 ms
11,588 KB
testcase_44 AC 28 ms
11,624 KB
testcase_45 AC 28 ms
11,304 KB
testcase_46 AC 28 ms
11,588 KB
testcase_47 AC 27 ms
11,684 KB
testcase_48 AC 28 ms
11,548 KB
testcase_49 AC 27 ms
11,516 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] = a * v
end
for k, v in pairs(ydv) do
  if not xdv[k] then ans(false) end
  if xdv[k] < b * v then ans(false) end
end
ans(true)
0