You must take in account that only 26 TopCoders has solved this probem. It rather involved and demand education level. For your training only I can said: 1. If stronng comp is not simple circle and can be go in from s and after t is achivebale then: -1 2. If only simple circles we met then: it's number mines one. it is coin change asymptotics.