結果

問題 No.428 小数から逃げる夢
ユーザー nobigomu
提出日時 2018-06-06 12:55:24
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,503 bytes
コンパイル時間 34 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 10:14:36
合計ジャッジ時間 2,610 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

D='123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
    7980818283848586878889909192939495969798991'
print((function (f, g, N)
if N=="1" then return "0."..D end
if N=="10" then return D:sub(1,1).."."..D:sub(2) end
if N=="100" then return D:sub(1,2).."."..D:sub(3) end
if #N==1 then return f(tonumber(N),0) end
if N:sub(2,2)=="0" then return f(tonumber(N:sub(1,1)),1) end
return g(tonumber(N:sub(1,1)),tonumber(N:sub(2,2)))
end)(function (n, idx)
local a={}
local t=tonumber(D:sub(#D))*n
local c=math.floor(t/10)
table.insert(a,1,t%10)
for i=#D-1,1,-1 do
t=tonumber(D:sub(i,i))*n+c
c=math.floor(t/10)
table.insert(a,1,t%10)
end
if c~=0 then table.insert(a,1,c) end
if idx+#a-#D==0 then table.insert(a,1,"0.") else table.insert(a,1+idx+#a-#D,".") end
return table.concat(a)
end, function (m, n)
local a={}
local t=tonumber(D:sub(#D))
local t2,t1=t*m,t*n
local c2,c1=math.floor(t2/10),math.floor(t1/10)
table.insert(a,1,t1%10)
t=tonumber(D:sub(#D-1,#D-1))
t1=t*n+c1
c1=math.floor(t1/10)
table.insert(a,1,(t2+t1)%10)
local c=t2%10+t1%10>9 and 1 or 0
t2=t*m+c2
c2=math.floor(t2/10)
for i=#D-2,1,-1 do
t=tonumber(D:sub(i,i))
t1=t*n+c1
c1=math.floor(t1/10)
table.insert(a,1,(t2%10+t1%10+c)%10)
c=t2%10+t1%10+c>9 and 1 or 0
t2=t*m+c2
c2=math.floor(t2/10)
end
table.insert(a,1,t2+c1+c)
table.insert(a,1+#a-#D,".")
return table.concat(a)
end, io.stdin:read("*l")))
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0