# 递归问题

假设你有一个3升的容器和一个5升的容器（以及充足的水源），如何精确地取出4升水来？

（为了下文叙述的方便，我们不妨把3升的容器和5升的容器分别记做容器A和容器B）。这里提供一种解法：

将A装满（3升），全部倒入B 再次将A装满（3升），用A中的水将B装满，此时A有1升，B有5升 B中的水全部倒出，将A中的1升水倒入B，此时A没有水，B有一升 再次将A装满（3升），将A中的水全部倒入B，此时B中恰有4升的水&#x20;

这样的问题存在一个万能的解法吗？答案是肯定的。注意到，用3升的容器和5升的容器量出4升的水，这一看似复杂的步骤可以简单地概括为：不断地将整杯整杯的A往B里倒，期间只要B被装满就把B倒空。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mm.ricky.moe/algorithm/algorithm-and-data-structure/di-gui/di-gui-wen-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
