#P8925. 「GMOI R1-T2」Light
「GMOI R1-T2」Light
Background
Prerequisite knowledge: the imaging principle of plane mirrors.
Because Baidu’s explanation is not very clear, if you do not understand something you can search by yourself, and you can also read the sample explanation of this problem.
Problem Description
The corridor can be regarded as an infinitely long coordinate axis. There is a lamp at the origin , and there are two mirrors at coordinates and . These two mirrors form an endless corridor of lights.
Why is it endless? Because, in theory, infinitely many images of the lamp can appear in these two mirrors. Now, please find the coordinate of the -th image on the left or on the right of this lamp.
Input Format
The first line contains an integer , the number of queries.
The second line contains two integers , with the meaning as described in the statement.
Then follow lines. Each line first inputs a character, then a number . If the character is L, it means the left side; if it is R, it means the right side. You need to output the coordinate of the -th image on the left or on the right.
It is guaranteed that the character is one of L or R.
Output Format
Output lines, each containing one integer, the coordinate value.
2
3 5
L 1
R 1
-6
10
Hint
For of the data: , , .
Constraints
| Test Point | Score | |||
|---|---|---|---|---|
Translated by ChatGPT 5