#abc271g. G - Access Counter
G - Access Counter
Score : points
问题陈述
高桥决定在他的网页上放置一个网页计数器。
访问他网页的情况如下:
- 对于 ,每天的 点钟都有可能进行访问:
- 如果
T
,高桥访问该网页的概率为 %。 - 如果
A
,青木访问该网页的概率为 %。 - 高桥或青木是否访问网页在每次都是独立决定的。
- 如果
- 没有其他访问来源。
另外,高桥认为自从放置计数器以来,第 次访问最好是不由他自己发起的。
如果高桥在某天 恰好在 0 点前 放置计数器,请计算(模 )第 次访问是由青木发起的概率。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi has decided to put a web counter on his webpage.
The accesses to his webpage are described as follows:
- For , there is a possible access at o'clock every day:
- If
T
, Takahashi accesses the webpage with a probability of percent. - If
A
, Aoki accesses the webpage with a probability of percent. - Whether or not Takahashi or Aoki accesses the webpage is determined independently every time.
- If
- There is no other access.
Also, Takahashi believes it is preferable that the -th access since the counter is put is not made by Takahashi himself.
If Takahashi puts the counter right before o'clock of one day, find the probability, modulo , that the -th access is made by Aoki.
Notes
We can prove that the sought probability is always a finite rational number. Moreover, under the constraints of this problem, when the value is represented as with two coprime integers and , we can prove that there is a unique integer such that and . Find this .
Constraints
- is
T
orA
. - , , and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1 50 50
ATATATATATATATATATATATAT
Sample Output 1
665496236
The -st access since Takahashi puts the web counter is made by Aoki with a probability of .
Sample Input 2
271 95 1
TTTTTTTTTTTTTTTTTTTTTTTT
Sample Output 2
0
There is no access by Aoki.
Sample Input 3
10000000000000000 62 20
ATAATTATATTTAAAATATTATAT
Sample Output 3
744124544
update @ 2024/3/10 11:26:52