20190725 summer training adder (the Add)

Description] [Title math, n digits written on a blackboard, referred to as A1 to An, fateice repeated several times following operations:

  1. Select two identical parity integer Ai and Aj, wipe them

  2. Ai + Aj write on the blackboard on the blackboard and asked whether there might ultimately only a number

[] The first line of input data input to a second row of n integers n, represents A1 ... An

[Output] data if possible only a number, output YES, otherwise output NO

Sample input [1] 3123

[1] Sample Output YES

Sample input [2] 512 345

[2] Sample Output NO

[Data] range for 10% of data, n = 2 to 100% of the data 2 <= n <= 10 ^ 5, 1 <= Ai <= 10 ^ 9

 

Because each removal the same numbers and add two parity combined, the resulting even number will

Finally, you want to get a number, then n numbers must all be converted to an even number

It is determined whether the number is an even number to an odd

#include <bits/stdc++.h>
using namespace std;
int main(){
    freopen("add.in", "r", stdin);
    freopen("add.out", "w", stdout);
    int n;
    int ocnt=0;
    scanf("%d", &n);
    int temp;
    for(int i=0; i<n; i++){
        scanf("%d", &temp);
        if(temp%2 == 1) ocnt++;
    }
    if(ocnt%2 == 1){
        printf("NO");
        return 0;
    }
    else printf("YES");
     return 0;
}

 

Guess you like

Origin www.cnblogs.com/miserweyte/p/11259148.html