-
Notifications
You must be signed in to change notification settings - Fork 0
/
ODD_TOTAL.C
43 lines (28 loc) · 735 Bytes
/
ODD_TOTAL.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
You are given an array A of N integers. Count the number of ways you can choose a pair (i, j), 1≤i<j≤N, i≠j, such that A_i + A_j is odd.
Input format:
The first line contains a single integer N.
The second line contains N integers representing the elements of A.
Output format:
Print the answer on the first line.
Example:
Input:
4
1 2 3 4
Output:
4
***********************************************************************************************************
// SPDX-License-Identifier: X11
// 2020-08-29
//Odd Sum (Easy)
#include <stdio.h>
int main() {
int N;
scanf("%d\n", &N);
int a;
int A[2] = {0, 0};
for (int i=0;i< N;i++) {
scanf("%d", &a);
A[a & 1]++;
}
printf("%d\n", A[0] * A[1]);
}