31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8730 – 0378 == 8352; n 5;8532 – 2358 == 6174; n 6;Task: The first member n 1of the sequence is given. Write a program to find thenumber of the last member (it is equal to 6174) of sequence.For example, if the input is 7815, the result should be equal to 6.49STAGE IIJUNIOR DIVISIONy 1X 3234. Parallel Sorting (theoretical task). Sequences of1 5 3 2 9 8numbers often have to be sorted in ascending or descendingorder. During the process of sorting, elements of sequencesPicture 234.1are compared andswapped. Sometimes theseX 1 y 1= min(x 1, x 2)actions can be performed inparallel. Consider the sequenceX 2 y 2= max(x 1, x 2)at picture 234.1.Two pairs of elementsPicture 234.2Picture 234.3can be compared andswapped at the same moment:x 1the second elementwith the fourth one and thefifth with the sixth one – thesorted sequence is obtained.Comparator is used inX 2y 2y 3algorithms of parallel sorting.It is a circuit having twoX 4y 4Picture 234.4inputs and two outputs (picture234.2: inputs are on theleft, outputs – on the right).X 1For example, whenx 1=3, x 2=1, we obtain situationin pict. 234.3.Comparators are joinedX 3with each other and so sortingnetworks are obtained.They sort members of sequencein ascending order. X 5Undoubtedly, not everysuch network sort sequence X 6completely Consider the exampleon pict. 234.4.Picture 234.53 11 3X 2 y 2y 3X 4 y 4y 1y 5y 6

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

Saved successfully!

Ooh no, something went wrong!