結果
問題 | No.1176 少ない質問 |
ユーザー |
👑 |
提出日時 | 2020-11-26 10:32:44 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 138 ms / 1,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 138 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 20:43:59 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
local ffi = require("ffi")local C = ffi.Cffi.cdef[[long long atoll(const char*);]]local function lltonumber(str)return C.atoll(str)endlocal a = io.read()a = lltonumber(a)-- find min n*m where a <= n^m-- 2 <= a <= 10^18local function llmin(x, y) return x < y and x or y end-- m = 1local ans = a-- m = 2local min, max = 0LL, 1000000007LLwhile 1LL < max - min dolocal mid = (min + max) / 2LLif a <= mid * mid thenmax = midelsemin = midendendans = llmin(ans, max * 2LL)-- 3 <= mfor i = 2, 1000001 dolocal li = 1LL * ilocal ta = a - 1LLlocal m = 1while li <= ta dom = m + 1ta = ta / liendans = llmin(ans, li * m)endans = tostring(ans):gsub("LL", "")print(ans)