Memsql start[c]up 2.0-round 1 (bored practiced hand b)

Source: Internet
Author: User

Http://codeforces.com/contest/452/problem/B B. 4-point polylinetime limit per test2 secondsmemory limit per test256 megab Ytesinputstandard Inputoutputstandard Output

You is given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. Choose exactly 4 different points to build a polyline possibly with Self-intersections and self-touching. This polyline should is as long as possible.

A polyline defined by points p1, P2, p3, p4 consists of the line s Egments P1 P2, p2 P3, p3 p 4, and its length are the sum of the lengths of the individual line segments.

Input

The only line of the input contains the integers n and m (0≤ n, m≤1000). It is guaranteed this grid contains at least 4 different points.

Output

Print 4 lines with the integers per line separated by space-coordinates of points p1, P2, P 3, p4 in order which represent the longest possible polyline.

Judge program compares your answer and jury ' s answer with 6 precision.

Sample Test (s) input
1 1
Output
1 1
0 0
1 0
0 1
Input
0 10
Output
0 1
0 10
0 0
2 {

--------------------------------------------------------------------------------------------------------------- ---

It's about giving you a rectangular area where you can draw three lines and draw the longest line.

According to the size of N and M, there are four kinds of drawing, one is X type, the other is diagonal Z type

#include <cstdio>#include<cmath>using namespacestd;intMain () {intn,m; scanf ("%d%d",&n,&m); if(n==0) {printf ("0 1\n0%d\n0 0\n0%d\n", m,m-1); }    Else if(m==0) {printf ("1 0\n%d 0\n0 0\n%d 0\n", N/A1); }    Else if(m>=N) {if(2*sqrt (m*m+n*n) +m<sqrt (m*m+n*n) +2*SQRT (m*m+ (n1) * (n1)) printf ("1 0\n%d%d\n0 0\n%d%d\n", n,m,n-1, M); Elseprintf"0 0\n%d%d\n%d 0\n0%d\n", n,m,n,m); }    Else    {        if(2*sqrt (m*m+n*n) +n<sqrt (m*m+n*n) +2*SQRT (M-1) * (M-1) (+n*n)) printf ("0 1\n%d%d\n0 0\n%d%d\n", n,m,n,m-1); Elseprintf"0 0\n%d%d\n0%d\n%d 0\n", N,m,m,n); }    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.