编程介的小学生 2019-12-31 01:11 采纳率: 20.5%
浏览 96

Sequence Folding 序列的问题

Problem Description
Alice and Bob are practicing hard for the new ICPC season. They hold many private contests where only the two of them compete against each other. They almost have identical knowledge and skills, the matter which results many times in ties in both the number of problems solved and in time penalty! To break the tie, Alice and Bob invented a tie breaker technique called sequence folding! The following are the steps of this technique:
1- Generate a random integer N >= 2.
2- Generate a sequence of N random integers.
3- If N = 2 go to step 6.
4- Fold the sequence by adding the Nth element to the first, the N-1th element to the second and so on, if N is odd then the middle element is added to itself, figure 1 illustrates the folding process.
5- Set N = ceil (N/2) and go to step 3.
6- The sequence now contains two numbers, if the first is greater than the second then Alice wins, otherwise Bob wins.

Figure 1.a Before Folding

Figure 1.b After one step of folding

Figure 1.c After two steps of folding, Alice wins!

In this problem you’re given the sequence of N integers and are asked determine the contest winner using the sequence folding tie breaker technique.

Input
The first line contains T (1 <= T <= 100), the number of test cases. The first line of each test case contains an integer (2 <= N <= 100), the number of elements of the sequence. The next line contains N space separated integers. The sum of any subset of the numbers fit in a 32 bit signed integer.

Output
For each test case print the name of the winner. Follow the output format below.

Sample Input
2
5
2 5 10 3 -4
3
5 4 -3

Sample Output
Case #1: Alice
Case #2: Bob

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog