{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"有一个留学生来xx大学读书,xx大学每周固定在其中的某些天为留学生上课.\u003cbr\u003e\n用一个长度为7的数组a[]表示,如果a[i]\u003d1则说明星期i的时候,xx大学这一天为留学生上课,否则如果为0,则留学生这一天不上课(不上课也要待在学校!).\u003cbr\u003e\n现在给你数组a,以及这个留学生想要上课的天数k.\u003cbr\u003e\n请问这个留学生最少要在学校呆多少天(他可以在任意一天来),才能满足他上满k天的课的要求?"}},{"title":"Input","value":{"format":"HTML","content":"输入的第一行有一个正整数T(1\u003c\u003dT\u003c\u003d10000)表示数据组数.\u003cbr\u003e\n每组数据第一行为一个正整数k(1\u003c\u003dk\u003c\u003d10^8).\u003cbr\u003e\n每组数据第二行为7个整数ai(0\u003c\u003dai\u003c\u003d1).\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"输出有T行,分别表示每组数据,想要满足上满k天的课的要求,最少要在学校呆的天数。"}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3\n2\n0 1 0 0 0 0 0\n100000000\n1 0 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e8\n233333332\n1\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"第一个样例,这个人可以在星期二来,然后再到下一个星期的星期二上完课再走,恰好上满两节课,总共在学校呆了8天。"}}]}