結果

問題 No.2125 Inverse Sum
ユーザー 👑 obakyanobakyan
提出日時 2022-11-25 12:51:42
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 20:58:52
合計ジャッジ時間 1,346 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,944 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

--[[
(x + y) / xy = p / q
xyp = (x + y)q
y = xq / (xp - q)
]]
p, q = io.read("*n", "*n")
local t = {}
for x = 1, 32000 do
  local a = x * q
  local b = x * p - q
  if 0 < b and a % b == 0 then
    local y = math.floor(a / b)
    if x < y then
      table.insert(t, {x, y})
      table.insert(t, {y, x})
    elseif x == y then
      table.insert(t, {x, x})
    end
  end
end

table.sort(t, function(a, b) return a[1] < b[1] end)
print(#t)
for i = 1, #t do
  print(t[i][1] .. " " .. t[i][2])
end
0