UVA10506 The Ouroboros problem

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=17&page=show_problem&problem=1447 [PDF](https://uva.onlinejudge.org/external/105/p10506.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10506/741619666094db3aa3196c113a93df50a6bb891c.png)

Input Format

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

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10506/9653d02c74ae2839ecc4243bccef5914a0efaab8.png)