[Huawei OD machine test real questions python] classic screensaver [2023 Q2 | 100 points]

Description of topic

【Classic Screensaver】

When the DVD player is outputting video, in order to protect the TV picture tube, a "screen saver animation" will be displayed in the standby state, as shown in the figure below, the DVD Logo moves back and forth within the screen, and will bounce when it touches the edge:

Please implement the calculation algorithm of the screen saver Logo coordinates according to the following requirements.

1. The screen is a rectangle of 800*600 pixels. It is stipulated that the coordinate origin of the upper left corner of the screen is the X axis along the horizontal side to the right, and the Y axis along the vertical side down direction;

2. The Logo is a rectangle of 50*25 pixels. In the initial state, the coordinates of the upper left corner are marked as (x, y), and it starts to move at a speed of 1 pixel/second in both the X and Y directions;

3. After encountering the four edges of the screen, a mirror bounce will occur, that is, it will collide with the edge at 45°, and then change the direction and pop out at 45°;

4. When the Logo collides with the four corners, the effect of the two edges bouncing at the same time is that the Logo will go back the same way.

Please code to realize the coordinates of the upper left corner of the Logo after t seconds.

enter description

Enter 3 numbers, separated by spaces:
xyt
The first number indicates the initial X coordinate of the upper left corner of the Logo; the
second number indicates the initial Y coordinate of the upper left corner of the Logo;
the third number indicates the time t, which is required by the title The position of the upper left corner of the Logo after t seconds.

output description

Output 2 numbers, separated by spaces:
xy
The first number means t seconds later

Guess you like

Origin blog.csdn.net/xiao_pengjy/article/details/131547182