oj1029: john games (puzzles)

Topics requirements
john invented a fun game, called mike play.
This game is so, john write down a row of numbers. Since a row is, of course, inclusive slightly.
john and mike can only head or tail from taking a number of rows of numbers.
Who takes the last number and more, whoever won. If the two men as much as, first take the wins.
Now your task is to determine in the case of the two men always make the best decisions (two person's IQ is very high ......),
who can win the final victory of it?
Input
first line a number k (k <= 10), expressed k sets of test data.
The k sets of test data.
Each set of test data, a first line only the even n (0 <= 100000 <n )
of the second row has only a number 1 indicates the first access john, mike 0 indicates the first access.
The third row has the number n , a row number is given john. N the absolute value of this number does not exceed 1e6.
The Output
test data output line for each group
represents in the case of the two men always make the best decisions,
the ultimate winner's name, ie "john" or "mike" (quotation marks not output).
The Input the Sample
Raw
2
2
. 1
. 1. 3
2
0
. 1. 3
the Sample the Output
Raw
John
Mike
Odd co separated (s1) and the even and (s2) in a consecutive number, the first person can choose to just get s1 or s2, selected at this point that in a large number of two can win. In short, who should hand who wins.

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
using namespace std;
int str[100005];
int main()
{
    int n, num, sign, i;
    cin >> n;
    while (n--)
    {
        cin>>num>>sign;
        for (i = 0; i < num; i++)
            cin>>str[i];
        if (sign == 1)
            printf("john\n");
        else
            printf("mike\n");
    }
    return 0;
}
Published 38 original articles · won praise 27 · views 3184

Guess you like

Origin blog.csdn.net/qq_45891413/article/details/104909492