Programming assignment question (Java)

Click For Summary

Discussion Overview

The discussion revolves around a programming assignment related to a problem from Peking University's online judge, specifically focusing on calculating whether points lie within a growing semi-circle. Participants explore the implications of the problem's unclear specifications regarding the growth rate of the semi-circle.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about the problem statement, particularly regarding the growth rate of the semi-circle and how to determine if points are within it without that information.
  • Another participant suggests modeling the growth of the semi-circle and calculating the area change to determine when a point will be contained within it, introducing a formula for area change.
  • A follow-up response confirms the approach of analyzing the radius change to check point inclusion.
  • There is a discussion about the relationship between the radii at different years, with one participant noting a potential constant rate but questioning the relationship between the radii.
  • Participants discuss the mathematical relationship for calculating the next radius based on area change.
  • Questions arise regarding data types for input and calculations, specifically whether to use float or double types, with differing opinions on the assignment's requirements.
  • Clarifications are made about the assignment's input specifications, with one participant acknowledging a misunderstanding after a correction.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the growth rate of the semi-circle or the best approach to handle data types for input. There are competing views on whether to use float or double for calculations.

Contextual Notes

The discussion highlights uncertainties regarding the problem's specifications, particularly the growth rate of the semi-circle and the implications for calculations. There are also unresolved aspects related to data type handling in the programming context.

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   Reactions: 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 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 16 ·
Replies
16
Views
13K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K