{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eYou are given multiple problems with three integers\n \u003cspan class\u003d\"tex2jax_process\"\u003e$p$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e, and \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e. Find \u003cspan class\u003d\"tex2jax_process\"\u003e$\\sum \\limits _{i\u003d1}^ n [(p{\\cdot }i) \\bmod\n {q}]$\u003c/span\u003e. That is, the first \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e multiples of \u003cspan class\u003d\"tex2jax_process\"\u003e$p$\u003c/span\u003e, modulo \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e, summed. Note that the overall sum\n has no modulus.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eEach input will begin with a line with a single integer\n \u003cspan class\u003d\"tex2jax_process\"\u003e$W$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1{\\le }W{\\le }10^5$\u003c/span\u003e), which is the\n number of cases you must solve.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$W$\u003c/span\u003e\n lines will contain three space-separated integers \u003cspan class\u003d\"tex2jax_process\"\u003e$p$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1{\\le }p,q,n{\\le }10^6$\u003c/span\u003e), which are\n the parameters of the problem as described above.\u003c/p\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eOutput \u003cspan class\u003d\"tex2jax_process\"\u003e$W$\u003c/span\u003e lines, each\n with the answer for a given instance of the problem, in the\n order that they appear in the input.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\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\n2 7 2\n1 4 5\n3 8 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n7\n37\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}