Discussion or tutorial for 2015-2016 XVI Open Cup, Grand Prix of Bashkortostan, SKB Kontur Cup Stage 2
Problem L - Liesbeth and the String
The observation is if n is even, then after applying n operations we get a string consisting of only (n/2) numbers of 'a'. On the other hand, if the n is odd, then after applying (n+1) operations we get a string consisting of only ( ( (3*(n+1)) / 2) -1) numbers of 'a'. So, we can run a loop and update n until it becomes 1. You may check the idea by writing some testcases on paper.
My Solution: https://vjudge.net/solution/36427286/mSvEESfhmwF1SloHe7PL