{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eConsider the following two sequences $P$ and $Q$. We denote $P(i)$ as the $i$-th element in sequence $P$, and $Q(i)$ as the $i$-th element in sequence $Q$:\u003c/p\u003e\r\n\r\n\u003cul\u003e\r\n \u003cli\u003eSequence $P$ is a \\textbf{sorted} sequence where for all $k \\in \\mathbb{Z^+}$, $k$ appears in sequence $P$ for $(k+1)$ times ($\\mathbb{Z^+}$ is the set of all positive integers). That is to say, $P \u003d \\{1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, \\dots \\}$\u003c/li\u003e\r\n \u003cli\u003eSequence $Q$ can be derived from the following equations: $\\begin{cases} Q(1) \u003d 1 \u0026amp; \\\\ Q(i) \u003d Q(i-1) + Q(P(i)) \u0026amp; \\text{if } i \u0026gt; 1 \\end{cases}$ That is to say, $Q \u003d \\{1, 2, 4, 6, 8, 12, 16, 20, 24, 30, 36, 42, 48, 54, 62, \\dots \\}$\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/71495d23404f5a3500cd8691cd4bc6d7?v\u003d1715576531\" style\u003d\"width: 400px\"\u003e\u003c/center\u003e\r\n\r\n\u003cp\u003eGiven a positive integer $n$, please calculate the value of $Q(n)$.\u003c/p\u003e\r\n\r\n\u003ch4\u003eInput\u003c/h4\u003e\r\n\u003cp\u003eThere are multiple test cases. The first line of the input contains an integer $T$ (about $10^4$), indicating the number of test cases. For each test case:\u003c/p\u003e\r\n\r\n\u003cp\u003eThe first and only line contains an integer $n$ ($1 \\le n \\le 10^{40}$).\u003c/p\u003e\r\n\r\n\u003ch4\u003eOutput\u003c/h4\u003e\r\n\u003cp\u003eFor each test case output one line containing one integer, indicating the value of $Q(n)$.\u003c/p\u003e\r\n\r\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\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\r\n10\r\n100\r\n1000\r\n987654321123456789\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e30\r\n2522\r\n244274\r\n235139898689017607381017686096176798\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n"}}]}