{"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":"Some people believe that there are three cycles in a person\u0027s life that start \nthe day he or she is born. These three cycles are the physical, emotional, and \nintellectual cycles, and they have periods of lengths 23, 28, and 33 days, respectively. \nThere is one peak in each period of a cycle. At the peak of a cycle, a person \nperforms at his or her best in the corresponding field (physical, emotional or \nmental). For example, if it is the mental curve, thought processes will be sharper \nand concentration will be easier. \n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003eSince the three cycles have different periods, the peaks of the three cycles \n generally occur at different times. We would like to determine when a triple \n peak occurs (the peaks of all three cycles occur in the same day) for any person. \n For each cycle, you will be given the number of days from the beginning of the \n current year at which one of its peaks (not necessarily the first) occurs. You \n will also be given a date expressed as the number of days from the beginning \n of the current year. You task is to determine the number of days from the given \n date to the next triple peak. The given date is not counted. For example, if \n the given date is 10 and the next triple peak occurs on day 12, the answer is \n 2, not 3. If a triple peak occurs on the given date, you should give the number \n of days to the next occurrence of a triple peak. \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\u003cbr\u003e\n \u003cbr\u003e\n You will be given a number of cases. The input for each case consists of one \n line of four integers p, e, i, and d. The values p, e, and i are the number \n of days from the beginning of the current year at which the physical, emotional, \n and intellectual cycles peak, respectively. The value d is the given date and \n may be smaller than any of p, e, or i. All values are non-negative and at most \n 365, and you may assume that a triple peak will occur within 21252 days of the \n given date. The end of input is indicated by a line in which p \u003d e \u003d i \u003d d \u003d \n -1. \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eOutput \u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n For each test case, print the case number followed by a message indicating the \n number of days to the next triple peak, in the form: \u003c/p\u003e\n\u003cp\u003eCase 1: the next triple peak occurs in 1234 days.\u003c/p\u003e\n\u003cp\u003eUse the plural form ``days\u0027\u0027 even if the answer is 1. \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Input\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n 1\u003c/p\u003e\n\u003cp\u003e0 0 0 0\u003cbr\u003e\n 0 0 0 100\u003cbr\u003e\n 5 20 34 325\u003cbr\u003e\n 4 5 6 7\u003cbr\u003e\n 283 102 23 320\u003cbr\u003e\n 203 301 203 40\u003cbr\u003e\n -1 -1 -1 -1\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output \u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n Case 1: the next triple peak occurs in 21252 days.\u003cbr\u003e\n Case 2: the next triple peak occurs in 21152 days.\u003cbr\u003e\n Case 3: the next triple peak occurs in 19575 days.\u003cbr\u003e\n Case 4: the next triple peak occurs in 16994 days.\u003cbr\u003e\n Case 5: the next triple peak occurs in 8910 days.\u003cbr\u003e\n Case 6: the next triple peak occurs in 10789 days.\u003cbr\u003e\n\u003c/p\u003e"}}]}