G. Ali and the Breakfast

Codeforces
IDCF10216G
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Ali Mansour was having a breakfast with his friends at the dorm. He will pour tea in their cups. He wanted to make the breakfast more exciting, so he decided to throw a drop of tea at their cups. Ali will throw the drop randomly from point $(0, 0)$ at a random (formally random) angle between $L$ and $R$ with initial speed $V$. He has $N$ friends, and each has a cup of different width. Let's assume that each cup has a $0$ height and is placed on the ground (The $X$ Axis). Given each cup's position, for each cup calculate the probability that the drop will fall in this cup. Note: it's possible for two cups to overlap or intersect. First line of input will be $T$ the number of test cases. Each test case is described by $4$ space separated integers, $N, V, L, R$ ($1 <= N <= 1000$), ($1 <= V <= 10^9$), ($0 <= L <= R <= 90$). Then $N$ lines, the positions of the cups ($X 1_i$, $X 2_i$), ($0 <= X 1_i < X 2_i <= 10^9$) For each test case print $N$ lines. in the $I_{t h}$ line print the probability that the drop will fall in the $I_{t h}$ cup. Print the probability rounded to exactly $4$ digits Consider $g$ = $10$ $m$.$s^(-2)$ ## Input First line of input will be $T$ the number of test cases.Each test case is described by $4$ space separated integers, $N, V, L, R$ ($1 <= N <= 1000$), ($1 <= V <= 10^9$), ($0 <= L <= R <= 90$).Then $N$ lines, the positions of the cups ($X 1_i$, $X 2_i$), ($0 <= X 1_i < X 2_i <= 10^9$) ## Output For each test case print $N$ lines. in the $I_(t h)$ line print the probability that the drop will fall in the $I_(t h)$ cup.Print the probability rounded to exactly $4$ digits [samples] ## Note Consider $g$ = $10$ $m$.$s^(-2)$
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case: - Let $ N \in \mathbb{Z} $ be the number of cups. - Let $ V > 0 $ be the initial speed (m/s). - Let $ L, R \in \mathbb{R} $ be the lower and upper bounds of the launch angle (degrees), with $ 0 \le L < R \le 90 $. - For $ i \in \{1, \dots, N\} $, let $ [x_{1,i}, x_{2,i}] \subset \mathbb{R}_{\ge 0} $ be the interval on the x-axis representing the $ i $-th cup’s width, with $ 0 \le x_{1,i} < x_{2,i} \le 10^9 $. - Let $ g = 10 \, \text{m/s}^2 $ be the gravitational acceleration. **Constraints** 1. $ 1 \le T \le \text{unknown} $ (implied by input format) 2. $ 1 \le N \le 1000 $ 3. $ 1 \le V \le 10^9 $ 4. $ 0 \le L < R \le 90 $ 5. $ 0 \le x_{1,i} < x_{2,i} \le 10^9 $ for all $ i \in \{1, \dots, N\} $ **Objective** For each cup $ i $, compute the probability $ P_i $ that a projectile launched from $ (0,0) $ with speed $ V $ and angle $ \theta \sim \text{Uniform}(L^\circ, R^\circ) $ lands within $ [x_{1,i}, x_{2,i}] $. The horizontal range of a projectile is: $$ x(\theta) = \frac{V^2 \sin(2\theta)}{g}, \quad \theta \in [L^\circ, R^\circ] $$ Convert angles to radians: $ \theta_{\text{rad}} = \theta \cdot \frac{\pi}{180} $. Let $ \Theta \sim \text{Uniform}(L, R) $ in degrees. Define the range function: $$ f(\theta) = \frac{V^2}{g} \sin\left(2 \cdot \theta \cdot \frac{\pi}{180}\right) $$ Then: $$ P_i = \mathbb{P}\left( x_{1,i} \le f(\Theta) \le x_{2,i} \right) = \frac{1}{R - L} \cdot \mu\left( \left\{ \theta \in [L, R] : f(\theta) \in [x_{1,i}, x_{2,i}] \right\} \right) $$ where $ \mu $ denotes Lebesgue measure (length) of the set of angles satisfying the condition. **Output** For each test case, output $ N $ lines, each containing $ P_i $ rounded to exactly 4 decimal places.
API Response (JSON)
{
  "problem": {
    "name": "G. Ali and the Breakfast",
    "description": {
      "content": "Ali Mansour was having a breakfast with his friends at the dorm. He will pour tea in their cups. He wanted to make the breakfast more exciting, so he decided to throw a drop of tea at their cups. Ali",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10216G"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Ali Mansour was having a breakfast with his friends at the dorm. He will pour tea in their cups. He wanted to make the breakfast more exciting, so he decided to throw a drop of tea at their cups.\n\nAli...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ N \\in \\mathbb{Z} $ be the number of cups.  \n- Let $ V > 0 $ be the initial speed (m/s).  \n- Let ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments