結果

問題 No.186 中華風 (Easy)
ユーザー 👑 obakyanobakyan
提出日時 2022-04-03 18:26:08
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 03:13:21
合計ジャッジ時間 1,077 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
5,248 KB
testcase_01 AC 6 ms
5,376 KB
testcase_02 AC 6 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 19 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 30 ms
5,376 KB
testcase_11 AC 23 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 23 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local function getgcd(x, y)
  while 0LL < x do
    x, y = y % x, x
  end
  return y
end

local function getlcm(x, y)
  local gcd = getgcd(x, y)
  return (x / gcd) * y
end

local x1, y1 = io.read("*n", "*n")
local x2, y2 = io.read("*n", "*n")
local x3, y3 = io.read("*n", "*n")
local v = x1 * 1LL
y1 = y1 * 1LL
x2 = x2 * 1LL
y2 = y2 * 1LL
x3 = x3 * 1LL
y3 = y3 * 1LL
local f = false
for irep = 1, 2000000 do
  if v % y2 == x2 then f = true break end
  v = v + y1
end
if not f then print(-1) os.exit() end
local lcm = getlcm(y1, y2)
f = false
for irep = 1, 2000000 do
  if v % y3 == x3 then f = true break end
  v = v + lcm
  if v < 0LL then break end
end
if not f then print(-1) os.exit() end
v = tostring(v):gsub("LL", "")
print(v)
0