Comp Sci Programming assignment question (Java)

AI Thread Summary
The programming assignment involves calculating whether points lie within a growing semicircle, as defined by Peking University's online judge problem. The semicircle's area increases at a rate of 50 square miles per year, which allows for the calculation of the radius over time. To determine if a point is inside the semicircle, the relationship between the radii of consecutive years must be analyzed using the formula for area change. Input values are specified as floating point numbers, and it's important to use the correct data type to avoid casting issues. Understanding these concepts is crucial for successfully completing the assignment.
kevinshen18
Messages
23
Reaction score
0
I'm not sure if I came to the right place/forum to ask this question, but I have a programming assignment and I need help on one of the question. It's part of the Peking University's online judge questions. It shouldn't be hard for people who understand it.

Link: http://poj.org/problem?id=1005

The question is unclear and confusing.
I don't understand the problem. The lost land forms a semi-circle, but I don't know if it increasing and it doesn't specify what rate. Is the semi-circle increasing at a specific rate? I understand the input and output part, but how am I supposed to calculate if the points are in the semi-circle without knowing it's growth rate?

I don't have any code as I haven't tried it yet because I don't understand.

I feel like I'm missing something.
 
Physics news on Phys.org
Its simple. You should model the growth of that semicircle and check in what year it will contain the point in question. The important point is that if the radius of the semicircle at year i is R_i, then, for the change of the semicircle's area during a year, we have \Delta A=\frac \pi 2 (R_{i+1}^2-R_i^2). But we know that \Delta A=50 \ miles^2/year so we can find R_{i+1} in terms of R_i which enables us to check whether a given point lies inside the semicircle or not.
 
  • Like
Likes 1 person
So I should look analyze the change in radius and use that to figure out if the point is in the semi-circle right?
 
Thanks!
 
(R^2i+1−R^2i) seems to be a constant rate of 31.85. However there is no relationship between Ri+1 and Ri.
 
R_{i+1}^2-R_i^2=\frac{2\Delta A}{\pi} \Rightarrow R_{i+1}=\sqrt{\frac{2\Delta A}{\pi}+R_i^2}
 
If the input is going to be floats and Ri+1 is a double then do I have to cast, if I am to make any calculations with those two?
 
kevinshen18 said:
If the input is going to be floats and Ri+1 is a double then do I have to cast, if I am to make any calculations with those two?
Why not take input as double, then you don't need to cast?
 
  • #10
I think the assignment asks for float input.
 
  • #11
kevinshen18 said:
I think the assignment asks for float input.
No, it doesn't. Quoting from what you posted, it says "These will be floating point numbers measured in miles." Both float and double are floating point types, as opposed to the integral types short, int, long, and the various signed or unsigned versions of these.
 
  • #12
Oh ok. Yea, I didn't read it properly. Thanks!
 

Similar threads

Replies
1
Views
1K
Replies
12
Views
2K
Replies
1
Views
2K
Replies
11
Views
1K
Replies
9
Views
2K
Replies
16
Views
13K
Back
Top