Create P161.java

A dirty Dynamic Programming solution. Unfortunately I wrote this a long time ago and it's all quite arcane now... will study this later.