Dstorv
시간 제한1초메모리 제한1024 MB
직선 위에서 왼쪽으로 가는 손과 오른쪽으로 가는 꽃이 충돌해 사라질 때, 충돌이 모두 끝난 뒤 꽃 A개와 손 B개가 남을 확률을 구한다.
문제
In a straight line, there is hand objects and flower objects moving in consistent speed. All hand objects move toward the left, and all flower objects move toward the right. The total number of objects are .
As the speed is consistent, no object of same type will collide to each other. However, there is a chance that the flower and hand might collide. In such case, one of them disappears, and other continues to move in the same direction in speed.
Which one to be removed, is determined by a probability. Flower object disappears with probability . Hand object disappears with probability . are the integers given as an input.
After a sufficient amount of time, there will be no collision, as hands would've all gone left, and flowers would've all gone right. Your task is to calculate the probability that there is exactly flower object and hand object remaining after all the collision.
입력
The first line of the input contains three integers . ()
The next line contains a string of length consisting of two character R, H. This denotes the initial placement of objects in left-to-right order. If a character is R, it denotes a flower object. If a character is H, it denotes a hand object.
The last line contains two integers . ()
출력
It can be shown that the answer can be represented as , where are coprime integer and .
Output the value of mod .
힌트
The answer for the sample is .