結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
👑 |
提出日時 | 2019-04-29 14:14:10 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 393 bytes |
コンパイル時間 | 49 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 08:41:14 |
合計ジャッジ時間 | 1,190 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
local str = io.read()local n = #strlocal t = {}for i = 1, n + 1 do t[i] = 0 endfor i = n, 1, -1 doif(str:sub(i, i) == "w") thent[i] = t[i + 1] + 1elset[i] = t[i + 1]endendlocal tot = 0local cpos = str:find("c")while(cpos ~= nil) doif(2 <= t[cpos]) thentot = tot + math.floor(t[cpos] * (t[cpos] - 1) / 2)endcpos = str:find("c", cpos + 1)endprint(tot)