POBEDA-2014
Time limit2sMemory limit1024 MB
Given counts of four fixed orientations of unit right isosceles triangles, find the largest axis-parallel square that can be tiled using them.
- Level
Medium7 of 10
- Topics
- Greedy, Math, Geometry, Binary search
- Solved
- No attempts yet
Problem
Modern video cards are known to build images using triangles only. The video card POBEDA-2014 keeps up with this trend. It can display only right isosceles triangles in the four orientations shown in the figures below. The card cannot change the orientation of these triangles.
The legs of each triangle shown above are one centimeter long. In one clock cycle the video card can display at most triangles of type .
You must find the maximum possible side length of a square that the video card can display on the monitor in one clock cycle. The sides of the square must be parallel to the edges of the monitor.
Write a program that solves this problem.
Input
The first line of the input file contains four integers separated by spaces: , , , (). The input can exceed the maximum value of a 32-bit data type.
Output
The output file must contain one number: the maximum possible side length of the square.
Notes
The figure below illustrates the first example.




