Programming contests

DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2024. december 1.

December 1, 2024, 10:00 AM – December 1, 2024, 3:00 PM

Binary transformations

The network monitoring system of the University of Debrecen, Faculty of Informatics noticed some strange signals. Unknown hackers tried to discover our network infrastructure by sending mysterious code sequences so that later they can launch a full scale attack against our servers. Your task is to stop this network mapping attack by altering the codes and thus relaying a false information back to the attackers.

Input

The input is a single (long) n integer terminated by an end of line symbol.

Output

The output is also a single positive (long) k integer, which we get by appending the shortest (but at least 1 character long) binary string to the end of the binary representation of n such that the resulting n' number becomes divisible by 5. If n is already divisible by 5, then you also need to append at least 1 character. If there are more than one such solutions, then append the smallest one. Note: shortest is not necessarily the smallest, since e.g. you may append "00001" to n, which is longer than e.g. "1111". So the "smallest" requirement is only relevant when you have two solutions with the same length.

Example

Explanation

8 = 1000 "1000"+"0" = 16 "1000"+"1" = 17 "1000"+"00" = 32 "1000"+"01" = 33 "1000"+"10" = 34 "1000"+"11" = 35
5 = 101 "101" + "0" = 10
University of Debrecen; Faculty of Informatics; v. 09/30/2024