TopCoder problem "Carbon14" used in TCO '03 Round 2 (Division I Level One)



Problem Statement

    A common way to determine the age of ancient organic artifacts is called Carbon-14 Dating. Carbon-14 is a radioactive isotope of carbon which is found in a relatively constant concentration in all living organisms. Once an organism dies, however, the carbon-14 in the remains of that organism begins to decay, and the concentration of carbon-14 in the remains starts to decrease. Thus, by comparing the concentration of carbon-14 in a neolithic wooden tool, for example, to the concentration typically found in living organisms, we can determine what percentage of the carbon-14 has decayed, and based on this, the age of the tool.



Radioactive isotopes generally decay according to the following function, where e is the base of the natural logarithm (about 2.718281828459045), t is the amount of time that has elapsed since the organism died, and k is a constant that is different for each isotope:

final concentration = initial concentration * (e ^ (- t / k))

In the case of carbon-14, k = 8267, when time is measured in years.



In this problem, you will be given a measurement, concentration, from an ancient artifact representing (final concentration / initial concentration) * 10,000 (so 543 would mean that the ratio of the two concentrations was 0.0543). You will also be given an int, err, indicating how far off this measurement could be. Your task is to determine a lower bound and an upper bound on the age of the artifact (in years). You should return a int[] with two elements. The first element should be the lower bound on the age of the artifact, and the second element should be the upper bound on its age. The lower bound should be rounded down (floor) and the upper bound should be rounded up (ceiling).



For example, if concentration were 5000 and err were 100, then the lower bound on the age of the artifact would come from assuming the true ratio of concentrations was 0.51, and the upper bound on the age of the artifact would come from assuming that the ratio of concentrations was 0.49. For these two concentrations, we get ages of 5566.54 and 5897.26, respectively. Thus we would return {5566, 5898}
 

Definition

    
Class:Carbon14
Method:dateRange
Parameters:int, int
Returns:int[]
Method signature:int[] dateRange(int concentration, int err)
(be sure your method is public)
    
 

Notes

-Recall that ln(e^x) = x, where ln is the natural logarithm function.
 

Constraints

-concentration will be between 1 and 9999, inclusive.
-err will be between 0, inclusive, and min(concentration, 10000-concentration), exclusive.
-Neither the lower nor the upper bounds on the age will be within 1e-6 of an integer, prior to rounding.
 

Examples

0)
    
5000
100
Returns: { 5566,  5898 }
The example from the problem statement.
1)
    
5000
0
Returns: { 5730,  5731 }
With 0 error, we calculate the age of the artifact as 5730.25 years, giving us a lower bound of 5730 and an upper bound of 5731. For this reason, 5730 years is called the half-life of carbon-14 - after 5730 years, there is half as much of it as there was originally.
2)
    
1
0
Returns: { 76141,  76142 }
3)
    
3456
18
Returns: { 8740,  8827 }

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1916

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4703&pm=1916

Writer:

lars2520

Testers:

Problem categories:

Math