Problem Statement
One of these games is the following:
Five girls sit down in a circle. We will label the girls 0 through 4 in the order in which they sit. Note that the girls 0 and 4 sit next to each other.
At the beginning of the game, each girl i picks a positive integer numbers[i] between one and ten thousand.
The game then proceeds in rounds.
Each round involves two girls that sit next to each other.
Both girls must have positive integers at the beginning of the round.
There are two possible actions they may perform:
- If both their integers are odd, they may perform the "apple action": they subtract 1 from each of their integers, and they share a glass of apple juice.
- They may always perform the "orange action": They divide both their integers by 2 (rounding down, if the result is not an integer) and share a glass of orange juice.
Elly once observed five of her friends playing this game. Elly recorded the game on a piece of paper: For each round, she wrote down the pair of girls that played in that round and the drink they chose. (The order in which she wrote down the two girls does not matter.) If the girls won the game, Elly gives the paper to you, otherwise she throws it away.
You are given the
Definition
- Class:
- EllysFiveFriends
- Method:
- getZero
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int getZero(int[] numbers)
- (be sure your method is public)
Constraints
- numbers will contain exactly 5 elements.
- Each element of numbers will be between 1 and 10000, inclusive.
Examples
{5, 1, 1, 2, 3}
Returns: 10
One of the ways in which the girls can win the game: Girls 0 and 1 drink orange juice. New integers: {2, 0, 1, 2, 3}. Girls 2 and 3 drink orange juice. New integers: {2, 0, 0, 1, 3}. Girls 3 and 4 drink apple juice. New integers: {2, 0, 0, 0, 2}. Girls 0 and 4 drink orange juice. New integers: {1, 0, 0, 0, 1}. Girls 0 and 4 drink apple juice. New integers: {0, 0, 0, 0, 0}. A different way of winning the game has the same first four steps, and then in step 5 girls 0 and 4 drink orange juice. Note that in step 2 girls 2 and 3 are not allowed to choose apple juice, as at that time at least one of their integers is even.
{2, 1, 1, 1, 2}
Returns: 0
Here the girls cannot win the game at all.
{3, 4, 1, 4, 5}
Returns: 520
Even with small numbers the answer can be rather big.
{42, 666, 1337, 666, 42}
Returns: 549119981
Don't forget to use modular arithmetics.
{8792, 9483, 6787, 9856, 6205}
Returns: 165501353
An almost maximal test case.
{10000, 10000, 10000, 10000, 10000}
Returns: 952019520
The maximal test case.
{8191, 7679, 8191, 8191, 8191}
Returns: 96943536
{8191, 8191, 8190, 8191, 7903}
Returns: 728000940
{4095, 4051, 4093, 3519, 4095}
Returns: 608507667
{4095, 3583, 4091, 4089, 3451}
Returns: 967786370
{8191, 8175, 8127, 8063, 8191}
Returns: 656575715
{4095, 4030, 3966, 4095, 4095}
Returns: 203058268
{7931, 8187, 8191, 8159, 8190}
Returns: 146106497
{8191, 8191, 8125, 7639, 8191}
Returns: 102760698
{8063, 8191, 8190, 7926, 8127}
Returns: 789018504
{108, 73, 59, 83, 15}
Returns: 649244340
{2092, 1860, 349, 381, 2832}
Returns: 214615257
{9798, 5127, 894, 9128, 2768}
Returns: 841058825
{7017, 9818, 5683, 7207, 5955}
Returns: 734167753
{3555, 7714, 8357, 4439, 6793}
Returns: 661903612
{2742, 9821, 5049, 4371, 7495}
Returns: 930810925
{5193, 3443, 9795, 1486, 6250}
Returns: 897813839
{8225, 8529, 9834, 7786, 2187}
Returns: 49502806
{7154, 2957, 6225, 7991, 7749}
Returns: 562815297
{9859, 4629, 6549, 6531, 3651}
Returns: 624046546
{5031, 5547, 8707, 3780, 5537}
Returns: 400625703
{8469, 7405, 8163, 3853, 8068}
Returns: 395506601
{169, 7018, 7084, 5327, 6545}
Returns: 652313592
{3237, 6061, 5507, 3920, 6217}
Returns: 19971835
{951, 7851, 6321, 3415, 5313}
Returns: 837691353
{2010, 7520, 8833, 8354, 8905}
Returns: 754040984
{8418, 581, 8344, 9486, 3132}
Returns: 822154940
{8886, 5191, 8213, 9, 9}
Returns: 0
{7492, 1995, 5732, 271, 8858}
Returns: 414992505
{7897, 5671, 8649, 7023, 2827}
Returns: 231179251
{8518, 2535, 7415, 3457, 1859}
Returns: 81672842
{1606, 3053, 1536, 7570, 6008}
Returns: 185784779
{2404, 10, 5038, 8, 9149}
Returns: 0
{1820, 4433, 8884, 2422, 255}
Returns: 554759739
{1, 9644, 3922, 2609, 6}
Returns: 0
{2498, 5732, 1690, 1011, 3803}
Returns: 968924112
{1190, 4946, 7461, 3925, 5134}
Returns: 440641162
{3086, 7583, 2192, 659, 7749}
Returns: 24615103
{5992, 5881, 3034, 3337, 694}
Returns: 804218287
{1860, 1174, 6724, 1740, 1025}
Returns: 512590207
{6358, 7358, 1843, 8781, 786}
Returns: 430596598
{5, 9, 4498, 1556, 6491}
Returns: 0
{5809, 822, 760, 1940, 6813}
Returns: 454768944
{7220, 2446, 3582, 9058, 4376}
Returns: 911310851
{8752, 6566, 4935, 1528, 4392}
Returns: 336988534
{3297, 7726, 5967, 4193, 3369}
Returns: 820360365
{737, 735, 2664, 895, 9904}
Returns: 316801226
{2499, 9093, 4383, 2180, 8155}
Returns: 988350005
{1772, 7305, 244, 9025, 8269}
Returns: 158795462
{2040, 381, 5423, 8998, 8028}
Returns: 337693647
{1435, 363, 7812, 1296, 5402}
Returns: 27382320
{2770, 5406, 186, 4, 9}
Returns: 80528650
{1217, 4084, 71, 2089, 2317}
Returns: 243838394
{1522, 1322, 8203, 3098, 9947}
Returns: 911633880
{1578, 8867, 8, 9524, 3}
Returns: 0
{5342, 2, 2230, 12, 2296}
Returns: 0
{1488, 3662, 7781, 620, 3687}
Returns: 656070496
{16, 2705, 2543, 7268, 10}
Returns: 0
{306, 9234, 4440, 278, 4200}
Returns: 367286490
{1556, 5902, 4732, 8048, 987}
Returns: 721180580
{5720, 9439, 13, 8038, 15}
Returns: 0
{10, 3358, 6786, 11, 2554}
Returns: 0
{7303, 1338, 5, 3434, 16}
Returns: 0
{3444, 9798, 1407, 7624, 8142}
Returns: 785574275
{9011, 7522, 3843, 8726, 72}
Returns: 857393969
{1, 1, 1, 1, 1}
Returns: 0
{10000, 10000, 10000, 10000, 10000 }
Returns: 952019520
{9878, 8786, 1234, 7685, 1233 }
Returns: 532330050
{133, 153, 117, 113, 107 }
Returns: 72658195