## The Odd Number

View as PDF

Points: 7
Time limit: 0.3s
C# 0.5s
JavaScript 0.5s
Memory limit: 2M
C# 37M
JavaScript 15M
Perl 6M
PyPy 2 10M
PyPy 3 11M
Python 2 10M
Python 3 11M

Author:
Problem type

Cindy has challenged Weiwei with a simple question today, and Weiwei promises to give the answer before lunch break, or else he is going to buy lunch for Cindy. There are only 5 minutes left until lunch starts, but Weiwei still has no idea whatsoever about how to solve this problem. You, as Weiwei's best friend, are trying to help him find out the answer.

Weiwei is given a multiset of integers. Out of all integers, only one appeared an odd number of times, and all others have appeared an even number of times. What is the value of this integer?

#### Input Specification

The first line of input contains the integer .

Next lines: one integer , which is a number in the multiset.

In the given multiset, exactly one integer will appear an odd number of times, and every other integer will appear an even number of times.

#### Output Specification

Output one integer, the integer that occurred an odd number of times.

#### Sample Input

5
3
3
18
4
4

#### Sample Output

18

• commented on July 30, 2024, 2:29 p.m.

Java 8 runs certain operations faster than Java (latest), which means that Java 8 can pass while Java (latest) TLEs.

• commented on May 21, 2022, 8:10 p.m.

if you want 5/7 of the points just submit your code but to COCI '14 Contest 2 #2 Utrka

• commented on June 30, 2021, 2:54 p.m.

I need the answer for c++. I can't solve it without a MLE. Where can I find the answer?

• commented on June 30, 2021, 3:58 p.m. edited

You can ask for help on discord

• commented on Jan. 26, 2021, 10:38 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Jan. 27, 2021, 1:24 a.m.
• commented on July 13, 2020, 4:36 a.m. edit 2

If the programming language you use takes more than 3 MB of ram to start and does not have a custom memory limit, feel free to open up a ticket.

Note that Python users should use the CPython interpreter instead of PyPy.

• commented on July 12, 2020, 5:34 p.m. edited

what if is 2?

• commented on July 12, 2020, 6:33 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 14, 2020, 3:51 a.m.

But what's gonna be the output?

• commented on July 14, 2020, 4:30 a.m.

Per the problem statement, the integer that appeared an odd number of times.

Note that your program can have undefined behavior on test cases that do not respect the input specification. Consider the following test case:

2
0
0

Your program can do anything when run on this test case - for example, it can crash or go into an infinite loop. It only needs to have the correct behavior on valid test cases.

• commented on July 12, 2020, 4:09 a.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 12, 2020, 7:05 p.m. edited

You have never made a submission that passed with a map to this problem; are you referring to someone else who passed with a map? If so, could you link their submission?

• commented on July 12, 2020, 10:49 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 13, 2020, 12:28 a.m.

Are you saying you could have theoretically passed with a map (i.e., no one has passed with a map)?

• commented on July 13, 2020, 12:50 a.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 17, 2018, 9:54 a.m.

How come I get a memory error from actually submitting nothing? Submitting 1 uses up 5.67 MB.

I'm not sure what I'm doing wrong

• commented on July 17, 2018, 10:32 a.m.

The problem isn't solvable in all languages, because of the low global memory limit. In particular, PyPy consumes a lot of memory.

• commented on June 26, 2018, 6:01 p.m.

Hint: If you keep getting TLE's in Java, try BufferedReader --> https://dmoj.ca/tips/

You might not need it but it will make your life much easier! :D

• commented on Aug. 16, 2017, 6:56 p.m.

Java outofmemory error?

• commented on Aug. 16, 2017, 9:09 p.m.

Your solution requires storing all integers, which takes memory. Try to aim for sublinear memory.

• commented on Dec. 25, 2015, 2:34 a.m.

Just wondering if this question is possible in Python?

• commented on Dec. 25, 2015, 2:35 a.m.

Yes, this problem is doable in any language (it is not computationally intensive).

• commented on July 18, 2017, 2:54 a.m. edited

I managed to find a method to fit my submission under the time limit, but it ends up exceeding the memory limit. If I import sys and read all the input data with sys.stdin.read().split('\n'), I get up to 100 M of memory. However, if I use any other method to read input it simply takes too long. There still has yet to be a precedent of a python solution to this problem.

• commented on Dec. 25, 2015, 2:50 a.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Sept. 20, 2015, 4:06 a.m. edited

Why did arock's solution pass using 26 MB? The problem description says its limited to only 4 MB.

• commented on Sept. 20, 2015, 2:08 p.m. edit 5

For Java, MLE is calculated based off the size of the Java heap. As such, it does not take the overhead of the JVM into account, though the number displayed for submission statuses is the memory the entire JVM took. arock's submission allocated under 4MB of heap space, though the overall JVM usage was much higher.

• commented on Sept. 19, 2015, 11:11 p.m. edited

Heya, got nothing but love for you guys; just pointing out a point inconsistency with Utrka (5 pts.)

• commented on Dec. 30, 2015, 3:16 a.m.

That question is actually a fair bit easier than this one. The solution I used on that one gives me both TLE and MLE on this one.

• commented on Aug. 9, 2017, 2:00 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Sept. 19, 2015, 2:02 a.m. edit 4

how do you solve this

seriously i have no intention of buying Cindy lunch

Edit: yay~

Edit: NO WTF OVER FIVE MINUTES