{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eXXX has an array of length n. XXX wants to know that, for a given w, what is the sum of the distinct elements’ number in all substrings of length w. For example, the array is { 1 1 2 3 4 4 5 } When w \u003d 3, there are five substrings of length 3. They are (1,1,2),(1,2,3),(2,3,4),(3,4,4),(4,4,5)\u003cbr\u003eThe distinct elements’ number of those five substrings are 2,3,3,2,2.\u003cbr\u003eSo the sum of the distinct elements’ number should be 2+3+3+2+2 \u003d 12\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are several test cases.\u003cbr\u003eEach test case starts with a positive integer n, the array length. The next line consists of n integers a\u003csub\u003e1\u003c/sub\u003e,a\u003csub\u003e2\u003c/sub\u003e…a\u003csub\u003en\u003c/sub\u003e, representing the elements of the array.\u003cbr\u003eThen there is a line with an integer Q, the number of queries. At last Q lines follow, each contains one integer w, the substring length of query. The input data ends with n \u003d 0 For all cases, 0\u0026lt;w\u0026lt;\u003dn\u0026lt;\u003d10\u003csup\u003e6\u003c/sup\u003e, 0\u0026lt;\u003dQ\u0026lt;\u003d10\u003csup\u003e4\u003c/sup\u003e, 0\u0026lt;\u003d a\u003csub\u003e1\u003c/sub\u003e,a\u003csub\u003e2\u003c/sub\u003e…a\u003csub\u003en\u003c/sub\u003e \u0026lt;\u003d10\u003csup\u003e6\u003c/sup\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, your program should output exactly Q lines, the sum of the distinct number in all substrings of length w for each query."}},{"title":"Sample","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\u003e7\r\n1 1 2 3 4 4 5\r\n3\r\n1\r\n2\r\n3\r\n0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\r\n10\r\n12\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}