DWITE '09 R1 #3 - That Missing Number

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE Online Computer Programming Contest, October 2009, Problem 3

You have a continuous sequence of unique numbers, 1 \dots N, that you like very much, but your little sister always steals one (and only one), and randomly re-arranges the rest in an attempt to hide the crime. Given N-1 numbers, in a random order, find out which number was taken.

The input will contain 5 sets of input. The first line will be an integer 1 \leq M \leq 100, the number of items remaining. Followed by M lines of unique integers, from at least 1 to at most M+1.

The output will contain 5 lines, each an integer from the missing set.

Note: the original sorted sequence is \{1, 2, 3,\ldots , N-1, N\}. Any of the numbers (including 1 or N) can be taken.

Sample Input

2
1
2
2
2
3
2
1
3

Sample Output

3
1
2

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments

There are no comments at the moment.