{"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\"\u003eMs. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine.\u003cbr\u003e\u003cbr\u003eFor example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg weights on the opposite side (Figure 1). Although she could put four 300mg weights on the medicine side and two 700mg weights on the other (Figure 2), she would not choose this solution because it is less convenient to use more weights.\u003cbr\u003e\u003cbr\u003eYou are asked to help her by calculating how many weights are required.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/ea85f6022de2c4812580282419cad2af?v\u003d1713841447\"\u003e\u003c/center\u003e\u003cbr\u003e\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input is a sequence of datasets. A dataset is a line containing three positive integers a, b, and d separated by a space. The following relations hold: a !\u003d b, a \u0026lt;\u003d 10000, b \u0026lt;\u003d 10000, and d \u0026lt;\u003d 50000. You may assume that it is possible to measure dmg using a combination of amg and bmg weights. In other words, you need not consider \"no solution\" cases. \u003cbr\u003e\u003cbr\u003eThe end of the input is indicated by a line containing three zeros separated by a space. It is not a dataset.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"The output should be composed of lines, each corresponding to an input dataset (a, b, d). An output line should contain two nonnegative integers x and y separated by a space. They should satisfy the following three conditions.\u003cbr\u003e\u003cpre\u003e\u0026nbsp;\u0026nbsp;1. You can measure dmg using x many amg weights and y many bmg weights.\u003cbr\u003e\u0026nbsp;\u0026nbsp;2. The total number of weights (x + y) is the smallest among those pairs of nonnegative\u003cbr\u003e\u0026nbsp;\u0026nbsp;integers satisfying the previous condition.\u003cbr\u003e\u0026nbsp;\u0026nbsp;3. The total mass of weights (ax + by) is the smallest among those pairs of nonnegative\u003cbr\u003e\u0026nbsp;\u0026nbsp;integers satisfying the previous two conditions.\u003c/pre\u003e\u003cbr\u003eNo extra characters (e.g. extra spaces) should appear in the output.\u003cbr\u003e"}},{"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\u003e700 300 200\r\n500 200 300\r\n500 200 500\r\n275 110 330\r\n275 110 385\r\n648 375 4002\r\n3 1 10000\r\n0 0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 3\r\n1 1\r\n1 0\r\n0 3\r\n1 1\r\n49 74\r\n3333 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}