{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"You are in a maze; seeing **n** doors in front of you in the beginning. You can choose any door you would like. The probability for choosing a door is equal for all the doors.\n\nIf you choose the **i\u003csup\u003eth\u003c/sup\u003e** door, it can either take you back to the same position where you began in **x\u003csub\u003ei\u003c/sub\u003e** minutes, or can take you out of the maze after **x\u003csub\u003ei\u003c/sub\u003e** minutes. If you come back to the same position, you can\u0027t remember anything. So, every time you come to the beginning position, you have no past experience.\n\nNow, you want to find the expected time to get out of the maze."}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026#8804; 100)**, denoting the number of test cases.\n\nEach case contains a blank line and an integer **n (1 \u0026#8804; n \u0026#8804; 100)** denoting the number of doors. The next line contains **n** space separated integers. If the **i\u003csup\u003eth\u003c/sup\u003e** integer **(x\u003csub\u003ei\u003c/sub\u003e)** is positive, you can assume that the **i\u003csup\u003eth\u003c/sup\u003e** door will take you out of the maze after **x\u003csub\u003ei\u003c/sub\u003e** minutes. If it\u0027s negative, then the **i\u003csup\u003eth\u003c/sup\u003e** door will take you back to the beginning position after **abs(x\u003csub\u003ei\u003c/sub\u003e)** minutes. You can safely assume that **1 \u0026#8804; abs(x\u003csub\u003ei\u003c/sub\u003e) \u0026#8804; 10000**."}},{"title":"Output","value":{"format":"MD","content":"For each case, print the case number and the expected time to get out of the maze. If it\u0027s impossible to get out of the maze, print `inf`. Print the result in `p/q` format. Where **p** is the numerator and **q** is the denominator of the result respectively. **p** and **q** should be relatively prime. See the samples for details."}},{"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\u003e3\n\n1\n1\n\n2\n-10 -3\n\n3\n3 -6 -9\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 1/1\nCase 2: inf\nCase 3: 18/1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}