added code for UVA:543
Merge pull request #1 from rahulroot/543-code

added code for UVA:543