added code for Uva:1124
Merge pull request #18 from rahulroot/1124-code

added code for Uva:1124