UVA12609 Sequential Thinking

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=602&page=show_problem&problem=4287 [PDF](https://uva.onlinejudge.org/external/126/p12609.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12609/c6ee592a3a9761993610a0d49b149c011ca30f86.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12609/4a0fbc97062684ca493098ca60be729117ca9ef5.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12609/958e6fee58a12b7f3f2d0235f8524946ffbe7816.png)