Arm Coordination
Time limit2sMemory limit1024 MB
Given a circle's integer center and radius, output four integer-coordinate corners of a smallest enclosing square.
- Level
Easy2 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
All the cool kids in town want to join the Bots and Androids Programmer Club (BAPC). To become a member, applicants must demonstrate their skill with a home-made robot programmed to perform some tricks. Like your older brother, you want to join the BAPC, so it is time to lock yourself in the hobby basement and start building robots.
Your older brother has used up almost all the parts for his own BAPC projects, so you have to get creative with whatever is left. You find a robotic arm with a single purpose: fitting circle-shaped objects into square-shaped holes. That is not exactly what you had in mind, but it will have to do. You have only five hours left to apply for BAPC membership.
The memory chip of the robotic arm appears to be wiped, but luckily you know the programming interface of its ARM processor. First, the robotic arm supports only integer coordinates. Second, when the arm picks up a circle-shaped object, you must calculate the smallest possible square it could fit the object in; after that, it will autonomously find a suitable square-shaped hole.
Given the location of a circle-shaped object, calculate the smallest possible square that encloses the object.
Input
The input consists of the following.
- One line contains two integers and (), the coordinates of the center of the circle.
- One line contains one integer (), the radius of the circle.
Output
Output four lines. Each line contains two integers: the - and -coordinates of one corner of the square. Print the corners in either clockwise or counter-clockwise order.
If there are multiple valid solutions, you may output any one of them.