Problem description Alice and Bob are practicing hard for the new ICPC season. they hold secret private contests where only the two of them compete against each other. they almost have identical knowledge and skills, the matter which results when times in ties in both the number of problems solved and in time penalty! To break the tie, Alice and Bob have Ted 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 into strates 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
Water question, according to the meaning of the question.
This means to fold a sequence and add the corresponding numbers.
If it is an odd number, you can add yourself to the number in the middle after the discount.
There are only two
If the first one is better than the second one, Alice wins.
#include <stdio.h>int main(){ int t,cas = 1; int a[105],i,n; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i = 0;i<n;i++) scanf("%d",&a[i]); while(n!=2) { for(i = 0;i<n;i++) a[i] = a[i]+a[n-i-1]; if(n%2) n = (n+1)/2; else n/=2; } printf("Case #%d: ",cas++); if(a[0]>a[1]) printf("Alice\n"); else printf("Bob\n"); } return 0;}