結果
問題 | No.428 小数から逃げる夢 |
ユーザー |
![]() |
提出日時 | 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 |
ソースコード
D='1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991'print((function (f, g, N)if N=="1" then return "0."..D endif N=="10" then return D:sub(1,1).."."..D:sub(2) endif N=="100" then return D:sub(1,2).."."..D:sub(3) endif #N==1 then return f(tonumber(N),0) endif N:sub(2,2)=="0" then return f(tonumber(N:sub(1,1)),1) endreturn g(tonumber(N:sub(1,1)),tonumber(N:sub(2,2)))end)(function (n, idx)local a={}local t=tonumber(D:sub(#D))*nlocal c=math.floor(t/10)table.insert(a,1,t%10)for i=#D-1,1,-1 dot=tonumber(D:sub(i,i))*n+cc=math.floor(t/10)table.insert(a,1,t%10)endif c~=0 then table.insert(a,1,c) endif idx+#a-#D==0 then table.insert(a,1,"0.") else table.insert(a,1+idx+#a-#D,".") endreturn table.concat(a)end, function (m, n)local a={}local t=tonumber(D:sub(#D))local t2,t1=t*m,t*nlocal 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+c1c1=math.floor(t1/10)table.insert(a,1,(t2+t1)%10)local c=t2%10+t1%10>9 and 1 or 0t2=t*m+c2c2=math.floor(t2/10)for i=#D-2,1,-1 dot=tonumber(D:sub(i,i))t1=t*n+c1c1=math.floor(t1/10)table.insert(a,1,(t2%10+t1%10+c)%10)c=t2%10+t1%10+c>9 and 1 or 0t2=t*m+c2c2=math.floor(t2/10)endtable.insert(a,1,t2+c1+c)table.insert(a,1+#a-#D,".")return table.concat(a)end, io.stdin:read("*l")))