{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e给定一棵树(一个无环的连通无向图)和一个整数 $$$s$$$。\u003c/p\u003e\u003cp\u003eVanya想要给树的所有边赋予权重,使得所有权重都是非负实数,它们的和为 $$$s$$$。同时,他希望使树的直径尽可能小。\u003c/p\u003e\u003cp\u003e我们定义一棵带权树的直径为树中两个顶点之间路径上边的权重之和的最大值。换句话说,带权树的直径是树中最长简单路径的长度,路径的长度等于路径上所有边的权重之和。\u003c/p\u003e\u003cp\u003e找出 Vanya 可以获得的最小可能直径。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含两个整数 $$$n$$$ 和 $$$s$$$($$$2 \\leq n \\leq 10^5$$$, $$$1 \\leq s \\leq 10^9$$$) — 树中顶点的数量和边权重之和。\u003c/p\u003e\u003cp\u003e接下来的 $$$n−1$$$ 行中,每行包含两个用空格分隔的整数 $$$a_i$$$ 和 $$$b_i$$$($$$1 \\leq a_i, b_i \\leq n$$$, $$$a_i \\neq b_i$$$) — 由一条边连接的顶点的索引。这些边是无向的。\u003c/p\u003e\u003cp\u003e保证给定的边构成一棵树。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e打印 Vanya 可以通过在树的边上放置一些非负实数权重,使其总和等于 $$$s$$$,得到的树的最小直径。\u003c/p\u003e\u003cp\u003e如果你的答案的绝对误差或相对误差不超过 $$$10^{-6}$$$,则视为正确。\u003c/p\u003e\u003cp\u003e形式上,设你的答案为 $$$a$$$,评测系统的答案为 $$$b$$$。如果 $$$\\frac {|a-b|} {max(1, b)} \\leq 10^{-6}$$$,则你的答案被视为正确。\u003c/p\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 3\n1 2\n1 3\n1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2.000000000000000000\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6 1\n2 1\n2 3\n2 5\n5 4\n5 6\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0.500000000000000000\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 5\n1 2\n2 3\n3 4\n3 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3.333333333333333333\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个示例中,需要这样设置权重:\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/bf615c14f095ae0bdf14d9a22ec47b40?v\u003d1713251383\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003e很容易看出这棵树的直径是 $$$2$$$。可以证明这是可能的最小直径。\u003c/p\u003e\u003cp\u003e在第二个示例中,需要这样设置权重:\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/9d54451665f733c66b3740641fddc896?v\u003d1713251383\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}}]}