I'm a beginner and quite new to programming. Have been trying to solve this problem http://www.spoj.com/problems/CPTTRN7/ since 2 days but I'm getting nowhere. Could someone suggest a solution via c++ please?