Cf #195 (div2) A: Vasily the bear and triangle

Source: Internet
Author: User

Http://codeforces.com/contest/336/problem/A

 

 

Vasily the bear hasFavorite rectangle, It has one vertex at Point
(0, limit 0), And the opposite vertex at Point
(X, Bytes,Y)
. Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.

Vasya also loves triangles, if the triangles have one vertex at Point
BLimit = limit (0, limit 0)
. That's why today he asks you to find two points
ASignature = Signature (X1, bytes,Y1)
And
CSignature = Signature (X2, bytes,Y2), Such that the following conditions hold:

    • the coordinates of points: x 1 ,
      x 2 ,
      Y 1
      , Y 2 are integers. besides, the following inequation holds:
      x 1 choice x 2 ;
    • the triangle formed by point A ,
      B
      and C is rectangular and isosceles (is right );
    • all points of the favorite rectangle are located inside or on the border of triangle
      ABC ;
    • the area of triangle ABC is as small as possible.

Help the bear, find the required points. It is not so hard to proof that these points are unique.

Input

The first line contains two integersX, Bytes,Y
(Cost-limit 109 bytes ≤ bytesX, Bytes,YLimit ≤ limit 109, middle,XLimit = Limit 0, limit,Y  =0 0).

Output

Print in the single line four IntegersX1, bytes,Y1, bytes,X2, bytes,Y2-The coordinates
Of the required points.

Sample test (s) Input
 
10 5
Output
 
0 15 15 0
Input
 
-10 5
Output
 
-15 0 0 15
Note

Figure to the first sample



 

 

Question: an equi right triangle with X and Y axes as the straight angle edge. It gives a point on the oblique edge. It requires the two endpoints of the oblique side to first output a small point of X.

Idea: Find the linear equation Y = K * x + D, and find K, D.

 

# Include <stdio. h> # include <string. h ># include <algorithm> using namespace STD; int main () {Double X, Y, a [2], B [2], K, M; while (~ Scanf ("% lf", & X, & Y) {If (x * Y> 0) // The slope is-1 {k =-1; M = Y + X; A [0] =-M/K; A [1] = 0; B [0] = 0; B [1] = m ;} else // The slope is 1 {k = 1; M = Y-X; A [0] =-M/K; A [1] = 0; B [0] = 0; B [1] = m;} if (a [0] <B [0]) {printf ("%. 0lf %. 0lf %. 0lf %. 0lf \ n ", a [0], a [1], B [0], B [1]);} else {printf (" %. 0lf %. 0lf %. 0lf %. 0lf \ n ", B [0], B [1], a [0], a [1]) ;}} return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.