結果
問題 |
No.1243 約数加算
|
ユーザー |
👑 |
提出日時 | 2021-06-13 17:07:55 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 5,504 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 05:42:25 |
合計ジャッジ時間 | 1,266 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
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 solve() local a, b = io.read():match("(%d+) (%d+)") a = lltonumber(a) b = lltonumber(b) local t = {} while a < b do local diff = b - a local mul = 1LL local tgt = 1LL while true do local v = mul + b % mul if diff < v then break end tgt = mul mul = mul + mul end mul = 1LL local v = tgt + b % tgt b = b - v while 0LL < v do if v % 2LL == 1LL then table.insert(t, mul) end v = v / 2LL mul = mul + mul end end print(#t) for i = #t, 1, -1 do local str = tostring(t[i]):gsub("LL", "") io.write(str) io.write(i == 1 and "\n" or " ") end end local q = io.read("*n", "*l") for iq = 1, q do solve() end