Bubbles must have areas proportional to their values. Compute honest radii and compare them with the misleading linear ones.
What to build
A program that computes bubble radii by area and by the wrong linear rule.
Requirements
- For each value, in order, print
V: radius A (linear B), with V as given, A = R × √(V ÷ max) and B = R × V ÷ max, both to one decimal.
Input
Line 1: R. Line 2: the values separated by spaces.
Output
One line per value.
Constraints
1 ≤ R ≤ 1000; 1 to 100 values, all over 0.
Example
Input:
20
100 25
Output:
100: radius 20.0 (linear 20.0)
25: radius 10.0 (linear 5.0)
Why it works
A circle's area grows with the square of its radius, so for the area to be proportional to the value the radius must grow with the square root of the value; a linear radius squares every difference.
Examples
20 100 25
100: radius 20.0 (linear 20.0) 25: radius 10.0 (linear 5.0)
10 4 1
4: radius 10.0 (linear 10.0) 1: radius 5.0 (linear 2.5)
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
The largest value gets the maximum radius R.
Hint 2
An honest radius is R × √(value ÷ max); the misleading linear one is R × value ÷ max.
Solution
Show one correct solution (try it yourself first)
r = float(input())
raw = input().split()
values = [float(v) for v in raw]
top = max(values)
for s, v in zip(raw, values):
print(f"{s}: radius {r * (v / top) ** 0.5:.1f} (linear {r * v / top:.1f})")