{"trustable":false,"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":"MD","content":"TXT 与 FGH 爆发了商业战。\n\n具体的说,TXT 与 FGH 所在的城市有 $n$ 个交叉口,其中一些通过双向道路连接。道路网络由 $n - 1$ 条道路组成,你可以通过这些道路从任何一个交叉口到达任何其他交叉口。没错,你猜对了 — 道路网络形成了一个无向树。\n\n现在 TXT 与 FGH 要在城市的交叉口建立自己的商店,并满足:\n\n- 每个交叉口最多只能有一个商店;\n- 每个商店要么属于 TXT ,要么属于 FGH ;\n- 每个人至少拥有一个商店(为了防止垄断);\n- 同一条道路两端的商店不能属于不同的人。\n\n为了更好的规划商店。请你找出所有这样的可能 $(a, b)$,即 $a$ 个商店属于 TXT ,$b$ 个商店可以属于 FGH ,并且 $a + b$ 的总和尽可能大。"}},{"title":"输入格式","value":{"format":"MD","content":"第一行输入包含整数 $n$ $(3 \\leq n \\leq 5000)$ —— 城市中的交叉路口数量。\n\n接下来的 $n - 1$ 行列出了每条路,每行一条路。\n\n每条路都以一对整数 $x_i, y_i$ $(1 \\leq x_i, y_i \\leq n)$ 表示 —— 连接的交叉路口的索引。\n\n保证给定的道路网络由 $n$ 个顶点的无向树表示。"}},{"title":"输出格式","value":{"format":"MD","content":"打印在第一行的整数 $z$ —— 所寻找的对的数量。\n\n然后按照 $a$ 的递增顺序打印所有的可能 $(a, b)$ 。"}},{"title":"样例 #1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\n1 2\n2 3\n3 4\n4 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n1 3\n2 2\n3 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例 #2","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10\n1 2\n2 3\n3 4\n5 6\n6 7\n7 4\n8 9\n9 10\n10 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n1 8\n2 7\n3 6\n6 3\n7 2\n8 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}