Benchmark AI / Public workspace

Humanity's Last Code Exam / 2012_B / Curvy Little Bottles

Problem

Answer published by the source. Consult the official source to check your work against its answer.

platform

atcoder

question content

**Problem Statement** In her bike rides around Warsaw, Jill happened upon a shop that sold interesting glass bottles. She thought it might make an interesting project to use such bottles for measuring liquids, but this would require placing markings on the bottles to indicate various volumes. Where should those volume marks be placed? Jill formalized the problem as follows. Assume a bottle is formed by revolving a shape that is the same as the graph of a polynomial P P between x=xlow x = x_{\text{low}} and x=xhigh x = x_{\text{high}} around the x-axis. Thus the x-axis is coincident with a vertical line through the center of the bottle. The bottom of the bottle is formed by a solid circular region at x=xlow x = x_{\text{low}} , and the top of the bottle, at x=xhigh x = x_{\text{high}} , is left open. The first sample input represents a bottle formed using the simple polynomial 40.25x 4 - 0.25x , with xlow=0 x_{\text{low}} = 0 and xhigh=12 x_{\text{high}} = 12 . The bottom of this bottle is a circle with a radius of 4, and the opening at the top is a circle with a radius of 1. The height of this bottle is 12. Volume markings are in increments of 25. Given a polynomial P P , xlow x_{\text{low}} , xhigh x_{\text{high}} , and the volume increment between successive marks on the bottle, compute the distances up from xlow x_{\text{low}} for the marks at successive volume increments. A mark cannot be made past the top of the bottle, and no more than the first 8 increments should be marked. Assume the value of P P is greater than zero everywhere between xlow x_{\text{low}} and xhigh x_{\text{high}} . **Input** Each test case consists of three lines of bottle data: - Line 1: n n , the degree of the polynomial (an integer satisfying 0n10 0 \leq n \leq 10 ). - Line 2: a0,a1,,an a_0, a_1, \ldots, a_n , the real coefficients of the polynomial P P defining the bottle’s shape, where a0 a_0 is the constant term, a1 a_1 is the coefficient of x1 x^1 , and an a_n is the coefficient of xn x^n . For each i i , 100ai100 -100 \leq a_i \leq 100 , and an0 a_n \neq 0 . - Line 3: - xlow x_{\text{low}} and xhigh x_{\text{high}} , the real valued boundaries of the bottle (100xlow<xhigh100-100 \leq x_{\text{low}} < x_{\text{high}} \leq 100 and xhighxlow>0.1 x_{\text{high}} - x_{\text{low}} > 0.1). - inc \text{inc} , an integer which is the volume increment before each successive mark on the bottle (1inc500 1 \leq \text{inc} \leq 500 ). **Output** For each test case, display the case number and the volume of the full bottle on one line. On a second line, display the increasing sequence of no more than 8 successive distances up from the bottom of the bottle for the volume markings. All volumes and height marks should be accurate to two decimal places. If the bottle does not have a volume that allows at least one mark, display the phrase `insufficient volume`. No test case will result in a mark within 0.01 from the top of the bottle. The volume of the bottle will not exceed 1000. All rounded distances for marks on a bottle differ by at least 0.05. **Sample Input**
Plain-text mathematical notation (without MathML)
**Problem Statement**

In her bike rides around Warsaw, Jill happened upon a shop that sold interesting glass bottles. She thought it might make an interesting project to use such bottles for measuring liquids, but this would require placing markings on the bottles to indicate various volumes. Where should those volume marks be placed?

Jill formalized the problem as follows. Assume a bottle is formed by revolving a shape that is the same as the graph of a polynomial P between x=x_(low) and x=x_(high) around the x-axis. Thus the x-axis is coincident with a vertical line through the center of the bottle. The bottom of the bottle is formed by a solid circular region at x=x_(low), and the top of the bottle, at x=x_(high), is left open.

The first sample input represents a bottle formed using the simple polynomial 4−0.25x, with x_(low)=0 and x_(high)=12. The bottom of this bottle is a circle with a radius of 4, and the opening at the top is a circle with a radius of 1. The height of this bottle is 12. Volume markings are in increments of 25.

Given a polynomial P, x_(low), x_(high), and the volume increment between successive marks on the bottle, compute the distances up from x_(low) for the marks at successive volume increments. A mark cannot be made past the top of the bottle, and no more than the first 8 increments should be marked. Assume the value of P is greater than zero everywhere between x_(low) and x_(high).

**Input**

Each test case consists of three lines of bottle data:

- Line 1: n, the degree of the polynomial (an integer satisfying 0≤n≤10).
- Line 2: a₀,a₁,…,a_(n), the real coefficients of the polynomial P defining the bottle’s shape, where a₀ is the constant term, a₁ is the coefficient of x¹, and a_(n) is the coefficient of x^(n). For each i, −100≤a_(i)≤100, and a_(n)≠0.
- Line 3:
  - x_(low) and x_(high), the real valued boundaries of the bottle (−100≤x_(low)<x_(high)≤100 and x_(high)−x_(low)>0.1).
  - inc, an integer which is the volume increment before each successive mark on the bottle (1≤inc≤500).

**Output**

For each test case, display the case number and the volume of the full bottle on one line. On a second line, display the increasing sequence of no more than 8 successive distances up from the bottom of the bottle for the volume markings. All volumes and height marks should be accurate to two decimal places. If the bottle does not have a volume that allows at least one mark, display the phrase `insufficient volume`. No test case will result in a mark within 0.01 from the top of the bottle. The volume of the bottle will not exceed 1000. All rounded distances for marks on a bottle differ by at least 0.05.

**Sample Input**

Original LaTeX notation
**Problem Statement**

In her bike rides around Warsaw, Jill happened upon a shop that sold interesting glass bottles. She thought it might make an interesting project to use such bottles for measuring liquids, but this would require placing markings on the bottles to indicate various volumes. Where should those volume marks be placed?

Jill formalized the problem as follows. Assume a bottle is formed by revolving a shape that is the same as the graph of a polynomial \( P \) between \( x = x_{\text{low}} \) and \( x = x_{\text{high}} \) around the x-axis. Thus the x-axis is coincident with a vertical line through the center of the bottle. The bottom of the bottle is formed by a solid circular region at \( x = x_{\text{low}} \), and the top of the bottle, at \( x = x_{\text{high}} \), is left open.

The first sample input represents a bottle formed using the simple polynomial \( 4 - 0.25x \), with \( x_{\text{low}} = 0 \) and \( x_{\text{high}} = 12 \). The bottom of this bottle is a circle with a radius of 4, and the opening at the top is a circle with a radius of 1. The height of this bottle is 12. Volume markings are in increments of 25.

Given a polynomial \( P \), \( x_{\text{low}} \), \( x_{\text{high}} \), and the volume increment between successive marks on the bottle, compute the distances up from \( x_{\text{low}} \) for the marks at successive volume increments. A mark cannot be made past the top of the bottle, and no more than the first 8 increments should be marked. Assume the value of \( P \) is greater than zero everywhere between \( x_{\text{low}} \) and \( x_{\text{high}} \).

**Input**

Each test case consists of three lines of bottle data:

- Line 1: \( n \), the degree of the polynomial (an integer satisfying \( 0 \leq n \leq 10 \)).
- Line 2: \( a_0, a_1, \ldots, a_n \), the real coefficients of the polynomial \( P \) defining the bottle’s shape, where \( a_0 \) is the constant term, \( a_1 \) is the coefficient of \( x^1 \), and \( a_n \) is the coefficient of \( x^n \). For each \( i \), \( -100 \leq a_i \leq 100 \), and \( a_n \neq 0 \).
- Line 3:
  - \( x_{\text{low}} \) and \( x_{\text{high}} \), the real valued boundaries of the bottle (\(-100 \leq x_{\text{low}} < x_{\text{high}} \leq 100\) and \( x_{\text{high}} - x_{\text{low}} > 0.1\)).
  - \( \text{inc} \), an integer which is the volume increment before each successive mark on the bottle (\( 1 \leq \text{inc} \leq 500 \)).

**Output**

For each test case, display the case number and the volume of the full bottle on one line. On a second line, display the increasing sequence of no more than 8 successive distances up from the bottom of the bottle for the volume markings. All volumes and height marks should be accurate to two decimal places. If the bottle does not have a volume that allows at least one mark, display the phrase `insufficient volume`. No test case will result in a mark within 0.01 from the top of the bottle. The volume of the bottle will not exceed 1000. All rounded distances for marks on a bottle differ by at least 0.05.

**Sample Input**

Code

1
4.0 -0.25
0.0 12.0 25
1
4.0 -0.25
0.0 12.0 300
0
1.7841241161782
5.0 10.0 20
0
1.0
0.0 10.0 10

**Output for Sample Input**

Code

Case 1: 263.89
0.51 1.06 1.66 2.31 3.02 3.83 4.75 5.87
Case 2: 263.89
insufficient volume
Case 3: 50.00
2.00 4.00
Case 4: 31.42
3.18 6.37 9.55

question title

Curvy Little Bottles

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import