cswork / OA打开练习工作台

Goldman SachsOA #28

Plus Mult Array

估计简单评测数据准备中,可先阅读题面

考点(AI 标注)模拟/实现位运算

A is an array of integers described as {A[0], A[1], A[2], A[3],..., A[n-1]}. Perform the following calculations on the elements of A: (R_even = (((A[0] × A[2]) + A[4]) × A[6]) + A[8]) × ...) % 2 ) (R_odd = (((A[1] × A[3]) + A[5]) × A[7]) + A[9]) × ...) % 2 ) Notice that zero-indexing is used to calculate R_even and R_odd and they are always modulo 2. You can then use R_even and R_odd to determine if A is odd, even, or neutral using the criterion below: If R_odd > R_even, then A is ODD.

  • If R_even > R_odd, then A is EVEN.
  • If R_odd = R_even, then A is NEUTRAL. For example, given the array A = [12,3,5,7,13,12], calculations are:
  • R_even = (A[0] * A[2] + A[4]) % 2 = (12 * 5 + 13) % 2 = 73 % 2 = 1
  • R_odd = (A[1] * A[3] + A[5]) % 2 = (3 * 7 +12) % 2 = 33 % 2 = 1 Since both are 1, the answer is NEUTRAL.

Constraints

No constraints are mentioned for input.

Example 1

Input:

A = [12, 3, 5, 7, 13, 12]

Output:

"NEUTRAL"

Explanation: Perform the operations as follows: R_even = (12 * 5 + 13) % 2 = 73 % 2 = 1 R_odd = (3 * 7 + 12) % 2 = 33 % 2 = 1 Both R_even and R_odd are equal, hence A is NEUTRAL.