#P10520. [XJTUPC 2024] 榕树之心

[XJTUPC 2024] 榕树之心

Background

You are right, but “Core of the Banyan Tree” is a strategy multiplayer battle game developed by Corycle, HCCH, MCPlayer542, Veritas, and wh in a game design and development course. The game takes place in a tropical rainforest. Here, you will play as the “core” of a banyan tree, competing with other banyan trees for nutrients and living space.

Problem Description

The game map is made up of several regular hexagons. Players can control the banyan core to move from the center of one hexagon to the center of an adjacent hexagon, in order to strengthen branches, clear pests, grow new branches, or destroy other banyan trees.

A planar regular hexagonal grid can be viewed as an isometric projection of a 3D shape formed by stacking cubes (as shown in the figure). The projection of each cube is a regular hexagon, so the 3D coordinates of cubes can be used to represent hexagon coordinates. We set the center of one cube at the origin, and all cube center coordinates (x,y,z)(x,y,z) satisfy x+y+z=0x+y+z=0, so one dimension can be omitted, and we use (x,y)(x,y) to describe the center of the corresponding hexagon. This coordinate system is called the axial coordinate system.

The game uses the axial coordinate system to describe hexagon positions. To let players see the core’s position intuitively, Veritas needs to convert it into Cartesian coordinates for display on the screen. Please help him convert axial coordinates into Cartesian coordinates.

The conversion formula from axial coordinates (x,y)(x,y) to Cartesian coordinates (x,y)(x^\prime,y^\prime) is:

x=12x+12yx^{\prime} = \frac{1}{2} x + \frac{1}{2} y $$y^{\prime} = \frac{\sqrt{3}}{2} x - \frac{\sqrt{3}}{2} y$$

Input Format

Only one line, with two integers x,yx,y separated by spaces, representing axial coordinates (x,y)(x,y) (106x106,106y106-10^6\le x\le 10^6,-10^6\le y\le 10^6).

Output Format

One line with two real numbers xx^{\prime} and yy^{\prime} separated by spaces, representing the converted Cartesian coordinates (x,y)(x^\prime,y^\prime).

Your output is considered correct if, for both real numbers, the smaller one of the relative error and absolute error compared to the answer is no more than 10610^{-6}.

114 514

314.000000 -346.410162
0 0

0.000000 0.000000
1000000 -1000000

0.000000 1732050.807569
3 5

4.000000 -1.732051
-19 23

2.000000 -36.373067

Hint

“Core of the Banyan Tree” game link (offline contest teams cannot access this link during the contest): core-of-banyan.github.io.

Everyone is welcome to play (after the contest).

Translated by ChatGPT 5