{"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\u003eA Niven number is a number such that the sum of its digits divides itself. \n For example, 111 is a Niven number because the sum of its digits is 3, which \n divides 111. We can also specify a number in another base b, and a number in \n base b is a Niven number if the sum of its digits divides its value.\u003c/p\u003e\n\u003cp\u003eGiven b (2 \u0026lt;\u003d b \u0026lt;\u003d 10) and a number in base b, determine whether it is \n a Niven number or not.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eThis problem contains multiple test cases!\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe first line of a multiple input is an integer N, then a blank line followed \n by N input blocks. Each input block is in the format indicated in the problem \n description. There is a blank line between input blocks.\u003c/p\u003e\n\u003cp\u003eThe output format consists of N output blocks. There is a blank line between \n output blocks.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eYou will be given a number of test cases. Each line of input contains the base \n b, followed by a string of digits representing a positive integer in that base. \n There are no leading zeroes. The input is terminated by a line consisting of \n 0 alone.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eFor each case, print \"yes\" on a line if the given number is a Niven \n number, and \"no\" otherwise.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e1\u003c/p\u003e\n\u003cp\u003e10 111\u003cbr\u003e\n 2 110\u003cbr\u003e\n 10 123\u003cbr\u003e\n 6 1000\u003cbr\u003e\n 8 2314\u003cbr\u003e\n 0\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eyes\u003cbr\u003e\n yes\u003cbr\u003e\n no\u003cbr\u003e\n yes\u003cbr\u003e\n no\u003cbr\u003e\n\u003c/p\u003e"}}]}