GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday 18 June 2022

[Solution] Circle Game Codeforces Solution


B. Circle Game
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Mike and Joe are playing a game with some stones. Specifically, they have n piles of stones of sizes a1,a2,…,an. These piles are arranged in a circle.

The game goes as follows. Players take turns removing some positive number of stones from a pile in clockwise order starting from pile 1. Formally, if a player removed stones from pile i on a turn, the other player removes stones from pile ((imodn)+1) on the next turn.

If a player cannot remove any stones on their turn (because the pile is empty), they lose. Mike goes first.

If Mike and Joe play optimally, who will win?

Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000). Description of the test cases follows.

Solution Click Below:-  CLICK HERE

The first line of each test case contains a single integer n (1≤n≤50)  — the number of piles.

The second line contains n integers a1,a2,…,an (1≤ai≤109)  — the size of the piles.

Output


For each test case print the winner of the game, either "Mike" or "Joe" on its own line (without quotes)

No comments:

Post a Comment