結果
問題 | No.492 IOI数列 |
ユーザー |
👑 |
提出日時 | 2020-04-22 13:00:30 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,035 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 5,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 04:49:46 |
合計ジャッジ時間 | 1,074 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
local mod = 1000000007local mfl = math.floorlocal function bmul(x, y)local x1, y1 = mfl(x / 31623), mfl(y / 31623)local x0, y0 = x - x1 * 31623, y - y1 * 31623return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % modendlocal function modpow(src, pow)local res = 1while 0LL < pow doif pow % 2LL == 1LL thenres = bmul(res, src)pow = pow - 1LLendsrc = bmul(src, src)pow = pow / 2LLendreturn resendlocal function modinv(src)return modpow(src, mod - 2LL)endlocal function lltonumber(str)local ret = 0LLfor i = 1, #str doret = ret * 10LL + str:sub(i, i):byte() - 48endreturn retendlocal n = lltonumber(io.read())local function solve2()local z = n % 11LLz = tostring(z):gsub("LL", "")z = tonumber(z)if z == 0 thenprint(0)elsefor i = 2, z doio.write("10")endio.write("1\n")endendlocal function solve1()local r = modpow(100, n)r = bmul(modinv(99), r - 1)print(r)endsolve1()solve2()