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.

48On the ground of values of these sums, it can be determined unambiguously, whetherthe mistake was made, and if so, the bad (altered) bit can be found.Task. A) Analyze the codes of Hamming, sums S 1, S 2, S 3and fill in the table above;B) Determine, if the encoded message 1100011 was transmitted correctly, and ifnot, restore the original coded message.232. Interest. A man went to borrow some money from a moneylender. The moneylenderagreed to lend and asked to repay money next month in the following way:on the first day of the month – 1 litas, on the second – two litas, on the third – fourlitas, i.e. every day to repay twice as much as the day before. On the day when the debtcould be paid off, the debtor would have to repay all rate of that day too. The overpaidsum would be the moneylender’s interest.A moneylender can lend not more than 30000 (thirty thousands) litas.Task. A moneylender reconsidered the situation and agreed to lend only if the loansum would be repaid in d days sharply, i.e. if in the way presented above it is notpossible to repay in other number of days.Write a program to calculate:a) how many litas it would be the most profitably to borrow for the man, i.e. whenthe interest in litas would be the least;b) how many litas it would be the most profitably to lend for the moneylender, i.e.when the interest in litas would be the biggest.Example. If number of days is 2, the most profitably for the man would be toborrow 3 litas, and the most profitably for the trader would be to lend 2 litas.233. Theorem 6174. Sequence 6174 is formed in the following way. The firstmember of the sequence is any tetra-signed number n 1. The only restriction: all fourdigits of this number can’t be equal (i.e. at least one must differ from the remainingthree). Two new numbers will be formed from the first member of the sequence. Thefirst number is obtained by sorting digits of n 1in descending order and the secondnumber will be obtained by sorting digits in ascending order. We subtract the secondnumber from the first one and obtain the second member n 2of the sequence. Againtwo new numbers are formed from n 2, the smaller is subtracted from the larger, thethird member of the sequence n 3is obtained, etc. Sequence is finished when its membersstart repeating (i.e. it can’t have two identical members). If the member of sequencehas less than four digits, then, sorting its digits (i.e. searching for further member),extra zero (or zeroes) is attached.Theorem 6174 states that the last member of the sequence formed in this way willalways be equal to 6174.Note: further members of the sequence will repeat, because 7641–1467==6174.Example: let us take the number 7815. It will be the first member n 1of the sequence:8751 – 1578 == 7173; n 2;7731 – 1377 == 6354; n 3;6543 – 3456 == 3087; n 4;

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

Saved successfully!

Ooh no, something went wrong!