← Back to the problem

Kazakhstan FAIO 2024 · Statement

C. Radioactive Decay

Formatted by IOAI Training from the original (BeksultanSagyndyk/faio-tasks, licence Apache-2.0). The original is authoritative.

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:

m(t)=m0(12)t/T0m(t) = m_0 \left(\frac{1}{2}\right)^{t / T_0}

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 {(xi,yi)}i=0n\{(x_i, y_i)\}_{i=0}^n that exhibits a linear relationship. We can model this relationship using the linear function f(x)=ax+bf(x) = ax + b, where aa and bb 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:

L(a,b)=1n∑i=0n(f(xi)−yi)2=1n∑i=0n(axi+b−yi)2→min⁡L(a, b) = \frac{1}{n}\sum_{i=0}^n\left(f(x_i) - y_i\right)^2 = \frac{1}{n}\sum_{i=0}^n\left(ax_i+b - y_i\right)^2 \rightarrow \min

By solving the equations ∂∂aL(a,b)=0\frac{\partial}{\partial a}L(a, b) = 0 and ∂∂bL(a,b)=0\frac{\partial}{\partial b}L(a, b) = 0, one can analytically determine the values of aa and bb.

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

  • nn: number of measurements.
  • mim_i: mass of the radioactive element (real number) at time tit_i (real number).

Constraints

  • 1<n≤10001 < n \le 1000
  • 1<mi≤100001 < m_i \le 10000
  • 1≤ti≤50001 \le t_i \le 5000

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

T0T_0

Sample Output

10.01

Подсказка

В решении этой задачи может оказаться полезным использовать натуральный логарифм.

from math import log