{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\r\nMathJax.Hub.Config({\r\n tex2jax: {\r\n inlineMath: [[\u0027$\u0027,\u0027$\u0027], [\u0027\\\\(\u0027,\u0027\\\\)\u0027]],\r\n skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"code\"]\r\n }\r\n});\r\n\u003c/script\u003e\r\n\u003cscript src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e\r\n\r\n\u003cp\u003e\r\n$S_{P2} \u003d \\{p \\mid p: \\mathrm{prime} \\wedge (\\exists x_1, x_2 \\in \\mathbb{Z}, p \u003d x_1^2 + x_2^2) \\}$ is the set of all primes that can be represented as the sum of two squares. The function $S_{P2}(n)$ gives the $n$\u003csup\u003eth\u003c/sup\u003e prime number from the set $S_{P2}$. Now, given two integers $n$ ($0 \u0026lt; n \u0026lt; 501$) and $k$ ($0 \u0026lt; k \u0026lt; 4$), find $p(S_{P2}(n), k)$ where $p(a, b)$ gives the number of unordered ways to sum to the given total ‘$a$’ with ‘$b$’ as its largest possible part.\r\n\r\nFor example: $p(5, 2) \u003d 3$ (i.e. $2+2+1$, $2+1+1+1$, and $1+1+1+1+1$). Here $5$ is the total with $2$ as its largest possible part.\r\n\r\n\u003c/p\u003e\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line gives the number of test cases $T$ followed by $T$ lines of integer pairs, $n$ and $k$. \u003c/p\u003e\r\n\r\n\u003ch3\u003eConstraints\u003c/h3\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e$0 \u0026lt; T \u0026lt; 501$\u003c/li\u003e\r\n\u003cli\u003e$0 \u0026lt; n \u0026lt; 501$\u003c/li\u003e\r\n\u003cli\u003e$1 \u0026lt; S_{P2}(n) \u0026lt; 7994$\u003c/li\u003e\r\n\u003cli\u003e$0 \u0026lt; k \u0026lt; 4$\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eThe $p(S_{P2}(n), k)$ for each $n$ and $k$. Append a newline character to every test cases’ answer.\r\n\r\n\u003c/p\u003e\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\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\u003e3\r\n2 2\r\n3 2\r\n5 3\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n7\r\n85\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\n\u003c/div\u003e"}}]}