added code for Uva:12372
Merge pull request #22 from rahulroot/12372-code

added code for Uva:12372