UVA10839 The Curse of Barbosa

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1780 [PDF](https://uva.onlinejudge.org/external/108/p10839.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10839/90c1111c38ba09241fa3b35ff1efd9cbb6671acf.png)

Input Format

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

Output Format

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