{"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\u003e\nPeople in Wonderland love watching movies. Recently, a very popular movie called Despicable Me 3 is on show and\npeople can\u0027t wait to enjoy it in the cinema. Obviously, everyone loves to take a seat in the row that is neither\ntoo far nor too near from the screen.\n\u003c/p\u003e\n\n\u003cp\u003e\nYou are the manager of a local cinema. Today, you have received many requests to book seats in a certain row. For convenience,\nlet\u0027s number the seats in that row from 1 to \\(M\\). People in Wonderland are crazy about maths, so they just want their seat number to\nbe a multiple of a certain number. Each seat can only be taken by at most one person. You have known that for \\(i\\) from 1 to 10,\nthere are \\(A_i\\) people wanting their seat numbers to be a multiple of \\(i\\). You task is to make full use of your math skills to satisfy as many people as possible.\n\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\n\u003cp\u003e\nThe first line contains a single interger \\(T\\) (about \\(10^4\\)), indicating the number of test cases. For each test case:\n\u003c/p\u003e\n\n\u003cp\u003e\nThe first line contains a positive interger \\(M\\) (\\(1 \\le M \\le 10^9\\)), indicating the number of seats in the row.\n\u003c/p\u003e\n\n\u003cp\u003e\nthe second line contains 10 integers \\(A_1, A_2, \\dots, A_{10}\\) (\\(0 \\le A_i \\le 10^9\\)), indicating that there are \\(A_i\\) people\nwanting their seat numbers to be a multiple of \\(i\\).\n\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\n\u003cp\u003e\nFor each case output one integer, indicating the maximum number of requests you can satisfy.\n\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\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\u003e2\n10\n2 1 4 0 0 0 0 0 0 0\n6\n0 2 0 1 0 0 0 0 0 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eHint\u003c/h4\u003e\n\n\u003cp\u003e\nThe first sample:\u003cbr\u003e\nThere are 10 seats numbered from 1 to 10.\u003cbr\u003e\nThere are 2 people wanting their seat number to be a multiple of 1, 1 person wanting his seat number to be a multiple of 2, and 4 people wanting their seat number to be a multiple of 3.\u003cbr\u003e\nThe 2 people wanting their seat number to be a multiple of 1 can take seats numbered 1 and 4.\u003cbr\u003e\nThe only person wanting his seat number to be a multiple of 2 can take seat numbered 2. \u003cbr\u003e\nThe 3 people wanting their seat number to be a multiple of 2 can take seats numbered 3, 6, 9.\n\u003c/p\u003e\n\n\u003cp\u003e\nThe second sampleļ¼\u003cbr\u003e\nThe 2 people wanting their seat number to be a multiple of 2 can take seats numbered 2, 6.\u003cbr\u003e\nThe only person wanting his seat number to be a multiple of 4 can take seat numbered 4.\n\u003c/p\u003e\n"}}]}