← 返回 meta 的题目列表Count Special Pairs (Even Product & Odd Distance)
类型:online_judge
Problem: Count Special Index Pairs
You are given an integer array nums of length n.
A pair of indices (i, j) is called special if:
0 <= i < j < n
nums[i] * nums[j] is even
(j - i) is odd
Return the number of special pairs in the array.
I/O Convention
Input: one line containing the integer array nums (space-separated)
Output: one integer, the number of special pairs
Constraints (typical interview setting)
1 <= n <= 2 * 10^5
-10^9 <= nums[i] <= 10^9
Examples
Input:
1 2 3 4
Output:
2
Input:
2 4 6
Output:
2
Input:
1 3 5
Output:
0
Input:
0 1 0 1
Output:
4
Input:
-1 -2 -3
Output:
1
Example
Input
1 2 3 4
Output
2