UVA13077 The merchant's riddle

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=866&page=show_problem&problem=4975 [PDF](https://uva.onlinejudge.org/external/130/p13077.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA13077/b2bc30c5dba8de6ee7f4913940a5cf7a089a4bc5.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA13077/35e91d9cb7d77684a0e22bc04eb4fca8c46d58a1.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA13077/d6635d5d24613904dc547687ab861afc7e84c958.png)