0% found this document useful (0 votes)
75 views1 page

Missing Building Finder for ACM Streets

1) John found that in the Amazing City of Mexico, every street is missing one building number between 1 and N, where N is the total number of buildings on that street. 2) John collected data on T streets and their building numbers, but finding the missing number for each street is difficult. 3) You must write a program that takes as input the number of streets T, the total buildings N for each street, and the numbers assigned to the existing buildings. The program should output the missing building number for each street.

Uploaded by

Abinadad Morales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views1 page

Missing Building Finder for ACM Streets

1) John found that in the Amazing City of Mexico, every street is missing one building number between 1 and N, where N is the total number of buildings on that street. 2) John collected data on T streets and their building numbers, but finding the missing number for each street is difficult. 3) You must write a program that takes as input the number of streets T, the total buildings N for each street, and the numbers assigned to the existing buildings. The program should output the missing building number for each street.

Uploaded by

Abinadad Morales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Concurso de programación ANIEI 2020 3

Problem B
Building lost
On the Amazing City of Mexico (ACM) each street has up to N buildings, each building of the street
has a number between 1 and N . If you were walking over the street, you will see that the numeration
of the buildings is ordered, this is, the first building has the number 1, the second building has the
number 2, and so on.
During the last ACM Programming Contest, John was instructed to give a tour to the foreign contes-
tants who are visiting the town, in this travel he found that all the streets have a missing building,
this is, there is a number X between 1 and N that no building in the street has that number, this as
you can see, means the street has only N − 1 buildings not N .
John is preparing a letter to the government where he will ask they to fix this problem, if there are
N − 1 buildings in the street they should numerate the buildings appropriately, He have colected the
numbering from T streets. Since some streets have a large amount of buildings, it is difficult for him
to find the missing building in all of them, that’s why he is requesting your help to write a program
that finds the missing building for each street.

Input
The first line of input is a single number T , followed by the description of the T streets. Each street
description starts with a line with a single number N followed by a line with N − 1 numbers showing
the numbers the buildings have.

• 1 ≤ T ≤ 100

• 1 ≤ N ≤ 100, 000

Output
For each test case print in one line the number X missing in that street.

Examples
Input Output
3 1
5 3
2 3 4 5 5
3
1 2
10
1 2 3 4 6 7 8 9 10

You might also like