Simple Polygon
Time limit1sMemory limit512 MB
Given a perimeter l and area s, construct a simple rectilinear polygon with exactly that perimeter and area, or report that none exists.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Although bobo is truly smart, he just wants you to find a simple polygon for him. The polygon you are going to find should satisfy the following conditions.
- The polygon is simple. That is to say, any two non-adjacent edges won't intersect or touch and any two adjacent edges have exactly one common point.
- Edges of the polygon are parallel to either the -axis or the -axis.
- The perimeter of the polygon equals , while the area equals .
Input
First line of the input contains two integers and ().
Output
The first line contains an integer , which denotes the number of vertices of the polygon you have found ().
Each of the following lines contains integers , which denote the coordinates of points (in clockwise or counter-clockwise order) ().
Any appropriate solution will get accepted.
If no such polygon can be found, simply print "-1".