Magical Runes
시간 제한1초메모리 제한1024 MB
A/B 룬들이 매일 왼쪽부터 규칙에 따라 뒤집히는 과정을 D일 동안 추적한다. 맨 오른쪽 룬은 B에서 A로 바뀌지 않는다는 조건이 주어지며, D일 뒤의 상태를 출력한다.
문제
You maintain a very nice collection of magical runes. They generally come in two types, type A and type B.
You have arranged your runes on a shelf to show them off. Because they are magical runes, they change each day. That is, at the start of each day the leftmost rune will switch its type (i.e. from A to B or from B to A, depending on its type just before the start of the day). Every other rune will only change if the type of the rune to its left changes from B to A.
For example, if you have three runes initially arranged like ABBAA, then at the start of the next day only the leftmost rune will change and the sequence will look like BBBAA. After another day, the leftmost rune will change, but then the second rune from the left will change because the rune beside it changed from B to A. But then the third rune will also change for the same reason. And then the fourth rune will also change! That is, after the changes at the start of this day the runes will look like AAABA.
Your task is the following. Given the initial states of an initial arrangement of runes and given a number of days 𝐷D, you should determine the states of the runes after days have elapsed.
입력
Input consists of a single line that first begins with a string followed by an integer . The length of will be between and (inclusive) and will consist only of characters A and B. The value satisfies .
Finally, you are also guaranteed that the rightmost rune does not change from B to A at the start of any of the days that you are to consider.
출력
Display a single string showing the states of the runes after days have elapsed, given they started in state .