https://contest.yandex.ru/contest/69765/problems/C/
Introduction
In physics, it is known that radioactive substances lose half of their activity or mass every T_0 seconds, which is described by the following equation:
You are given experimental results as n pairs of values (t, m(t)). Your task is to determine the half-life T_0.
For this task, you can use various heuristic methods or the classical linear regression method, after first transforming the data for convenience.
Linear Regression
Let’s consider a dataset that exhibits a linear relationship. We can model this relationship using the linear function , where and are the model parameters representing the slope and intercept, respectively.
The parameters of the resulting linear function can be determined by minimizing the mean squared deviation of each point from the line:
By solving the equations and , one can analytically determine the values of and .
Evaluation Criteria
If your prediction is within 1% of the correct answer, you will receive 100 points. Otherwise, the result will be 0. The final score will be calculated as the average of the scores across all test sets.
Input Format
n
m_1 t_1
m_2 t_2
...
m_n t_n
Description
- : number of measurements.
- : mass of the radioactive element (real number) at time (real number).
Constraints
Input example
5
1000 0
500 10
250 20
125 30
62.5 40.0
In this example:
There are 5 measurements. The initial mass is 1000. The half-life is 10 seconds.
Output Format
Sample Output
10.01
Подсказка
В решении этой задачи может оказаться полезным использовать натуральный логарифм.
from math import log