SPOJ 11354: Amusing numbers + scanner refactored