1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/速算机器人 [nGK0Fy].md

22 lines
783 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

小扣在秋日市集发现了一款速算机器人。店家对机器人说出两个数字(记作 `x``y`),请小扣说出计算指令:
- `"A"` 运算:使 `x = 2 * x + y`
- `"B"` 运算:使 `y = 2 * y + x`
在本次游戏中,店家说出的数字为 `x = 1``y = 0`,小扣说出的计算指令记作仅由大写字母 `A`、`B` 组成的字符串 `s`,字符串中字符的顺序表示计算顺序,请返回最终 `x``y` 的和为多少。
**示例 1**
>输入:`s = "AB"`
>
>输出:`4`
>
>解释:
>经过一次 A 运算后x = 2, y = 0。
>再经过一次 B 运算x = 2, y = 2。
>最终 x 与 y 之和为 4。
**提示:**
- `0 <= s.length <= 10`
- `s``'A'``'B'` 组成