UVA12852 The Miser's Puzzle

Description

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

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12852/3dfa33a2205c6dff4f4c3488d9c6d69db4cbacfa.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12852/3f0dc767d984428f5617f98cde896133d83f8eb5.png)