UVA12851 The Tinker's Puzzle

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=861&page=show_problem&problem=4716 [PDF](https://uva.onlinejudge.org/external/128/p12851.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12851/a10d34eface3c53ea3a57e33f914b2efd8e89b85.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12851/9f174510831c6a98124faccba3a0aa418d761f06.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12851/9ee53b600724db70e35f0caf354310a19345372b.png)