Monday, May 4, 2009

Row of simple problems from acm.timus.ru

1007. Code words.
Simple ad-hoc problem.

1008. Image encoding.
Problem is easily solvable using BFS. The only trick is that you problem statement doesn't really specify which (one of two) input format is going to be used... :)

1009. K-based numbers.
1012. K-based numbers v.2.
1013. K-based number v.3.
The three upper mentioned problems are solved using the exact same DP: dp[i][j] - number of valid K-based numbers of length i and last digit j. The only difference is the latter two have to be implemented using long arithmetic or java's BigInteger class.

1014. The product of Digits.
Simple math problem. There should be formula for it, but I solved using iterations, because given input is specified up to two decimal points...

1015. Test the Difference!
The problem requires to be able to generate all possible rotated states of the die and then determine dice are same. Pretty straightforward.

1017. The staircase.
Classical DP problem. Asks to find number of ways to represent a given integer N as an increasing sum of at least two integers. You have to use long arithmetics again or BigInteger, since N can be up to 500.

1 comment:

  1. Thank you very much for pointing out some timus site problems.

    ReplyDelete