#P6784. 「EZEC-3」造房子

    ID: 7529 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟贪心2020洛谷原创枚举洛谷月赛

「EZEC-3」造房子

Background

pigstd is going to build a house.

Problem Description

pigstd has aa units of material A and bb units of material B. Building the ii-th floor requires ii units of material A and ii units of material B.

However, pigstd thinks the house is not tall enough, so he takes out cc dollars. Each dollar can be used to buy 11 unit of material A or 11 unit of material B.

Now pigstd wants to know the maximum number of floors he can build.

Input Format

The first line contains three integers a,b,ca, b, c.

Output Format

Output one integer per line, representing the maximum number of floors pigstd can build.

1 2 3
2
1 5 3
2

Hint

[Sample 1 Explanation]

After pigstd buys 22 units of material A and 11 unit of material B, he will have 33 units of material A and 33 units of material B, so he can build at most a 22-floor house.

(It costs (1+2)(1 + 2) units of material A and (1+2)(1 + 2) units of material B.)

[Sample 2 Explanation]

After pigstd buys 33 units of material A, he will have 44 units of material A and 55 units of material B, so he can build at most a 22-floor house.

(It costs (1+2)(1 + 2) units of material A and (1+2)(1 + 2) units of material B.)

[Constraints]

For 100%100\% of the testdata, 0a,b,c10120 \le a, b, c \le 10^{12}.

Test Point ID Conditions Satisfied
14,221-4,22 c=0c = 0
58,215-8,21 a,b,c103a, b, c \le 10^{3}
9129-12 a,b,c106a, b, c \le 10^{6}
132013-20 a,b,c1012a, b, c \le 10^{12}

Translated by ChatGPT 5