{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t\u003d4, n\u003d6, and the list is [4,3,2,2,1,1], then there are four different sums that equal 4: 4,3+1,2+2, and 2+1+1.(A number can be used within a sum as many times as it appears in the list, and a single number counts as a sum.) Your job is to solve this problem in general. \n \u003cbr\u003e \n给你一个数t作为最后等式的和,再给你n个数作为等式的加数,每个加数最多只能使用一次,要求输出所有满足条件(加数从大到小输出)的等式,并且不能重复\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input will contain one or more test cases, one per line. Each test case contains t, the total, followed by n, the number of integers in the list, followed by n integers x1,...,xn. If n\u003d0 it signals the end of the input; otherwise, t will be a positive integer less than 1000, n will be an integer between 1 and 12(inclusive), and x1,...,xn will be positive integers less than 100. All numbers will be separated by exactly one space. The numbers in each list appear in nonincreasing order, and there may be repetitions. \n输入为先输入总数t,t\u003c\u003d1000,然后是后面的加数个数n,n\u003c\u003d12,然后是n个加数,出现的数字是非递增并且有可能重复的,当n\u003d0时结束。\n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, first output a line containing \u0027Sums of\u0027, the total, and a colon. Then output each sum, one per line; if there are no sums, output the line \u0027NONE\u0027. The numbers within each sum must appear in nonincreasing order. A number may be repeated in the sum as many times as it was repeated in the original list. The sums themselves must be sorted in decreasing order based on the numbers appearing in the sum. In other words, the sums must be sorted by their first number; sums with the same first number must be sorted by their second number; sums with the same first two numbers must be sorted by their third number; and so on. Within each test case, all sums must be distince; the same sum connot appear twice. \n对于每个测试用例,首先输出包含“ Sums of”,t和冒号的行。然后输出每个算式,每行一个;如果没有,则输出“ NONE”。每个算式内的数字必须以不递增的顺序出现。算式中可以重复的次数与原始列表中重复的次数相同。算式本身必须根据算式中出现的数字按降序排序。换句话说,算式必须按其第一个数字排序;第一个数字相同的和必须按第二个数字排序;前两个数字相同的则必须按第三个数字排序;以此类推。在每个测试用例中,所有算式必须是不同的。\n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e4 6 4 3 2 2 1 1\n5 3 2 1 1\n400 12 50 50 50 50 50 50 25 25 25 25 25 25\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eSums of 4:\n4\n3+1\n2+2\n2+1+1\nSums of 5:\nNONE\nSums of 400:\n50+50+50+50+50+50+25+25+25+25\n50+50+50+50+50+25+25+25+25+25+25\u003c/pre\u003e"}}]}