P16193 [ROIR 2014 Day 1] POBEDA-2014

Description

As everyone knows, modern graphics cards draw images by assembling triangles. The POBEDA-2014 graphics card is no exception: it can display only four orientations of isosceles right triangles, as shown in the figure below. The graphics card cannot change the orientation of these triangles. ![](https://cdn.luogu.com.cn/upload/image_hosting/ub3oluze.png) For each triangle, the length of each leg of the right angle is $1$ centimeter. In each clock cycle, the graphics card can display at most $a_i$ triangles of type $i$. Your task is to compute the maximum possible side length of a square that the graphics card can draw within one clock cycle. Note that the sides of this square must be parallel to the sides of the monitor. Write a program to solve this problem.

Input Format

The first line of the input contains four integers separated by spaces: $a_1, a_2, a_3, a_4\ (0 \le a_i \le 10^{18})$. Note that the input values may exceed the range of 32-bit integers.

Output Format

N/A

Explanation/Hint

The following figure is an illustration of the first sample, for reference. ![](https://cdn.luogu.com.cn/upload/image_hosting/qh0bz2ek.png) ### Scoring For the $50$-point testdata, $a_1, a_2, a_3, a_4 \le 100\,000$. Translation source: GPT 4.1 mini. Translated by ChatGPT 5