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.

230. 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.Task. Write a program to calculates how many interest in litas would a moneylenderget for the borrowed n litas.Example. If a man had borrowed 5 litas, a trader would get interest of 2 litas.47STAGE ISENIOR DIVISION231. Hamming Codes. (Theoretical problem). During transmission through telecommunicationnetwork, the messages (data) can be corrupted. To avoid this, messagesare coded. We will only analyze messages containing bits and such telecommunicationlines, which during transmission of one message, alter not more than one byte.A 4-bit message must be transmitted: p=b 1b 2b 3b 4. Bit is zero (0) or one (1). Possibleerror is replacing zero with one or vice versa. To identify bad bit three extra bitesare attached:b 5==b 2+b 3+b 4;b 6==b 1+b 3+b 4;b 7==b 1+b 2+b 4;Note: values of bytes are summed up with module two, i.e. adding two high bytes,zero byte is obtained.The encoded message contains seven bits: p coded=b 1b 2b 3b 4b 5b 6b 7. Such a code iscalled a code of Hamming.Consider the example: the message to be transmitted is 0110. We calculate:b 5=1+1+0=0;b 6=0+1+0=1;b 7=0+1+0=1.The encoded messagewill be: p coded=0110011.In order to find outwhether an error was made,the following sums are calculated(with module two):S 1==b 4+b 5+b 6+b 7;S 2==b 2+b 3+b 6+b 7;S 1 S 2 S 3 Which byte is the mistake made in0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1S 3==b 1+b 3+b 5+b 7; Picture 231.1

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

Saved successfully!

Ooh no, something went wrong!