31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50If inputs of network are equal to x 1=5, x 2=9, x 3=4, x 4=2, then outputs will beequal to: y 1=4, y 2=2, y 3=5, y 4=9.Task. Parallel sorting network is presented in the picture 234.5. The sequencebeing sorted is known too: x 1=6, x 2=5, x 3=4, x 4=3, x 5=2, x 6=1. Calculate the values ofy 1, y 2, y 3, y 4, y 5, y 6.235. Roman Numerals. Latin letters I, V, X, L, C, D, M, meaning numbers 1, 5, 10,50, 100, 500, 1000 accordingly, are used for writing Roman numerals. Value of a Romannumber is calculated in the following way: if the larger digit is before the smallerone or if two digits are the same, then they are added, and if the smaller digit is beforethe larger one, then the smaller one is subtracted from the larger digit. For example,MCXLIV == 1000 + 100 + 50 – 10 + 5 – 1 == 1144.These rules are not enough if one wants to find out how is the Roman numberbeing formed, but they can be used for convert Roman number into Arabic unambiguously.Assume, that the largest Roman number is MMMCMXCIX (3999).Task. Write a program to convert the given Roman number into Arabic.236. Three-digit Numbers. Given a sequence of digits. There is minus one (-1) atthe end of it. It does not belong to the sequence (it is not a digit), it just indicates theend of it. The sequence has not less than three members.Task. Write a program to calculate how many different three-number digits it ispossible to make each time taking 3 digits standing next to each other. Digits can notbe not exchanged; the first digit of number cannot be equal to 0.For example, if the input data are: 2 4 5 5 4 5 5 2 -1, the solution should be5, because five different three-digit numbers can be formed (245, 455, 554, 545, 552).STAGE IISENIOR DIVISION237. Parallel sorting (theoretical task). Sequences of numbers often have to besorted in ascending or descending order. During the process of sorting, elements ofsequences are compared and swapped. Sometimes these actions can be performed inparallel. Consider the sequence on pict. 234.1.Two pairs of elements can be compared and swapped at the same moment: thesecond element with the fourth one and the fifth with the sixth one – the sorted sequenceis obtained.Comparator is used in algorithms of parallel sorting. It is a circuit having twoinputs and two outputs (picture 234.2: inputs are on the left, outputs – on the right).For example, when x 1=3, x 2=1, we obtain situation in picture 234.3.Comparators are joined with each other and so sorting networks are obtained.They sort members of sequence in ascending order. Note that inputs and outputs of

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!