## [URI Online Judge] – 2290 – Apaixornados Numbers

December 4th, 2014 Comments off

Link: https://www.urionlinejudge.com.br/judge/en/problems/view/2290

You will be given an array of **N** numbers, where everyone will be in pairs. But two of those numbers ended up without peer, these numbers are said apaixornados numbers, you can identify what are that numbers?

For example, **A** = {1, 1, 3, 3, 5, 5, 5,7}, the apaixornados numbers are 5 and 7.

## Input

The input consists of several test cases. Each test case is composed of a line having an integer **N** (1 ≤ **N** ≤ 10^{5}), followed by **N** numbers (-10^{12} < **A** < 10^{12}). The input ends when **N** = 0 and it should not to be processed.

## Output

For each test case print only the apaixornados numbers in ascending order. It is guaranteed that only two numbers are alone.

Input Sample | Output Sample |

6 1 3 4 7 3 1 4 1 1 5 1 8 1 1 3 3 5 5 5 7 0 | 4 7 1 5 5 7 |

solve:

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 | #include <bits/stdc++.h> using namespace std; int main() { //freopen("in.txt","r",stdin); long long ar[100010]; int n; while(cin >> n and n != 0){ memset(ar,0,sizeof ar); int t = 0; for(int i = 0;i < n ; i++) cin >> ar[i]; sort(ar,ar+n); for(int i= 0 ; i < n and t < 2 ;){ if(ar[i] == ar[i+1] and i < n-1){ i += 2; }else{ cout << ar[i]; cout << ((t == 1) ? "\n" : " ") ; i++; t++; } } } return 0; } |