Recurrence

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3066 [PDF](https://uva.onlinejudge.org/external/119/p11915.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11915/503193a1cd3a6d2edb9a5b6e11293d75ae25f525.png)

输入输出格式

输入格式


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

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11915/81d9f81efe988d95ac0b18c24e131cb858508101.png)

输入输出样例

输入样例 #1

8
3
7 5 4
6
7 7 5 3 2 1
2
4 2
3
7 4 4
4
8 7 5 5
5
7 7 6 5 5
2
8 7
3
6 3 1

输出样例 #1

Case 1: 100100
Case 2: 398009117
Case 3: 9
Case 4: 25025
Case 5: 923714728
Case 6: 311516464
Case 7: 1430
Case 8: 315