{"problem":{"name":"D. Falling Anvils","description":{"content":"For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all. Anvils co","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF80D"},"statements":[{"statement_type":"Markdown","content":"For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.\n\nAnvils come in different sizes and shapes. Quite often they get the hero stuck deep in the ground. But have you ever thought who throws anvils from the sky? From what height? We are sure that such questions have never troubled you!\n\nIt turns out that throwing an anvil properly is not an easy task at all. Let's describe one of the most popular anvil throwing models.\n\nLet the height _p_ of the potential victim vary in the range \\[0;_a_\\] and the direction of the wind _q_ vary in the range \\[ - _b_;_b_\\]. _p_ **and** _q_ **could be any real (floating) numbers.** Then we can assume that the anvil will fit the toon's head perfectly only if the following equation has at least one real root:\n\nDetermine the probability with which an aim can be successfully hit by an anvil.\n\nYou can assume that the _p_ and _q_ coefficients are chosen equiprobably and independently in their ranges.\n\n## Input\n\nThe first line contains integer _t_ (1 ≤ _t_ ≤ 10000) — amount of testcases.\n\nEach of the following _t_ lines contain two space-separated integers _a_ and _b_ (0 ≤ _a_, _b_ ≤ 106).\n\nPretests contain all the tests with 0 < _a_ < 10, 0 ≤ _b_ < 10.\n\n## Output\n\nPrint _t_ lines — the probability of a successful anvil hit for each testcase. The absolute or relative error of the answer should not exceed 10 - 6.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"出于某种原因，在许多美国卡通中，铁砧会不时从天而降砸在主角头上。当然，保险箱、衣柜、巡洋舰、飞机有时也会掉下来……但最常掉的还是铁砧。\n\n铁砧有不同的尺寸和形状。它们常常把主角深深砸进地里。但你有没有想过，是谁从天上扔下铁砧的？从多高的地方扔的？我们相信，这样的问题从未困扰过你！\n\n事实证明，正确地扔下铁砧并不是一件容易的事。让我们描述其中最流行的一种铁砧投掷模型。\n\n假设潜在受害者的高度 #cf_span[p] 在范围 #cf_span[[0;a]] 内变化，风向 #cf_span[q] 在范围 #cf_span[[ - b;b]] 内变化。#cf_span[p] *和* #cf_span[q] *可以是任意实数（浮点数）*。那么我们可以假设，只有当以下方程至少有一个实根时，铁砧才能完美砸中卡通人物的头部：\n\n求铁砧成功击中目标的概率。\n\n你可以假设系数 #cf_span[p] 和 #cf_span[q] 在其范围内等概率且独立地选取。\n\n第一行包含整数 #cf_span[t] (#cf_span[1 ≤ t ≤ 10000]) —— 测试用例的数量。\n\n接下来的 #cf_span[t] 行每行包含两个用空格分隔的整数 #cf_span[a] 和 #cf_span[b] (#cf_span[0 ≤ a, b ≤ 106])。\n\n预测试包含所有满足 #cf_span[0 < a < 10, 0 ≤ b < 10] 的测试用例。\n\n请输出 #cf_span[t] 行 —— 每个测试用例中铁砧成功命中目标的概率。答案的绝对或相对误差不应超过 #cf_span[10 - 6]。\n\n## Input\n\n第一行包含整数 #cf_span[t] (#cf_span[1 ≤ t ≤ 10000]) —— 测试用例的数量。接下来的 #cf_span[t] 行每行包含两个用空格分隔的整数 #cf_span[a] 和 #cf_span[b] (#cf_span[0 ≤ a, b ≤ 106])。预测试包含所有满足 #cf_span[0 < a < 10, 0 ≤ b < 10] 的测试用例。\n\n## Output\n\n请输出 #cf_span[t] 行 —— 每个测试用例中铁砧成功命中目标的概率。答案的绝对或相对误差不应超过 #cf_span[10 - 6]。\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ a, b \\in \\mathbb{R}_{\\geq 0} $.  \nLet $ p \\sim \\mathcal{U}[0, a] $, $ q \\sim \\mathcal{U}[-b, b] $, with $ p $ and $ q $ independent.  \n\nConsider the quadratic equation:  \n$$\nx^2 + p x + q = 0\n$$\n\n**Constraints**  \n1. $ 1 \\leq t \\leq 10000 $  \n2. For each test case: $ 0 \\leq a \\leq 10^6 $, $ 0 \\leq b \\leq 10^6 $\n\n**Objective**  \nCompute the probability that the equation $ x^2 + p x + q = 0 $ has at least one real root, i.e., the discriminant satisfies:  \n$$\nD = p^2 - 4q \\geq 0\n$$  \nover the uniform distribution of $ p \\in [0, a] $, $ q \\in [-b, b] $.  \n\nThat is, compute:  \n$$\n\\mathbb{P}\\left(p^2 - 4q \\geq 0\\right) = \\frac{1}{a \\cdot 2b} \\iint\\limits_{\\substack{0 \\leq p \\leq a \\\\ -b \\leq q \\leq b \\\\ p^2 - 4q \\geq 0}} dq\\,dp\n$$  \nwhen $ a > 0 $ and $ b > 0 $. Handle edge cases ($ a = 0 $ or $ b = 0 $) appropriately.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF80D","tags":["geometry","probabilities"],"sample_group":[["2\n4 2\n1 2","0.6250000000\n0.5312500000"]],"created_at":"2026-03-03 11:00:39"}}