結果

問題 No.1842 Decimal Point
ユーザー 👑 obakyanobakyan
提出日時 2022-08-25 23:06:56
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 1,049 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 05:28:59
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 115 ms
6,944 KB
testcase_02 AC 371 ms
6,940 KB
testcase_03 AC 306 ms
6,940 KB
testcase_04 AC 232 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local mod = 1
local function bmulslow(x, y)
  local x1, y1 = x % 10000, y % 10000
  local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000
  local x3, y3 = mfl(x / 100000000), mfl(y / 100000000)
  local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod
  ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod
  ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod
  ret = (ret +  x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod
  return ret
end
local bmul = bmulslow

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local q = io.read("*n")
for iq = 1, q do
  local a, b, c = io.read("*n", "*n", "*n")
  mod = b
  a = a % b
  local rem = bmul(a, modpow(10, c - 1))
  local z = 0
  for i = 1, 9 do
    if rem * 10 < b * i then break end
    z = i
  end
  print(z)
end
0