結果

問題 No.25 有限小数
ユーザー 👑 obakyanobakyan
提出日時 2020-04-26 16:50:31
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 806 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 5,460 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 00:59:04
合計ジャッジ時間 1,772 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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 n = io.read()
n = lltonumber(n)
local m = io.read()
m = lltonumber(m)

while m % 10LL == 0LL do
  m = m / 10LL
end
while n % 10LL == 0LL do
  n = n / 10LL
end

while n % 2LL == 0LL and m % 2LL == 0LL do
  n = n / 2LL
  m = m / 2LL
end
while n % 5LL == 0LL and m % 5LL == 0LL do
  n = n / 5LL
  m = m / 5LL
end
local m2, m5 = 0, 0
while m % 2LL == 0LL do
  m2 = m2 + 1
  m = m / 2LL
end
while m % 5LL == 0LL do
  m5 = m5 + 1
  m = m / 5LL
end
if n % m ~= 0LL then
  print(-1)
  os.exit()
end
n = n / m
if 0LL < m2 then
  print(5)
  os.exit()
end
n = n % 10LL
n = tostring(n):gsub("LL", "")
n = tonumber(n)
for i = 1, m5 do
  n = (n * 2) % 10
end
print(n)
0