{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv align\u003d\"left\"\u003eInteger numbers from 1 to N are written in the increasing order, clockwise along the circle. You are moving from integer to integer sequentally. You start moving clockwise from 1. \u003cbr\u003eMoving operation consists of the following steps: \u003cbr\u003e1) You must count Q-th integer in your current moving direction and erase that integer. \u003cbr\u003e2) Then you must move to the next integer clockwise. \u003cbr\u003e3) If that integer is odd then your moving direction becomes clockwise (or nothing happens if you are already moving clockwise). \u003cbr\u003e4) If that integer is even then your moving direction becomes counter-clockwise (or nothing happens if you are already moving counter-clockwise). \u003cbr\u003e \u003cbr\u003eIf there are no integers left you stop the moving process. Your goal is to find the last erased integer. \u003cbr\u003eLet us consider the following example where N\u003d5 and Q\u003d3. The numbers will be deleted in the following order - 3, 1, 4, 5, 2. The last erased number is 2. \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003eThe first line of input contains N and Q (1\u0026lt;\u003dN\u0026lt;\u003d2000000; 1\u0026lt;\u003dQ\u0026lt;\u003d10). \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003eOutput the last erased integer. \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003e\u003cb\u003eSample test(s)\u003c/b\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003eInput\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cfont face\u003d\"Courier New\"\u003e\u003c/font\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cpre\u003e\u003c/pre\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003eTest #1 \u003cbr\u003e5 2 \u003cbr\u003e \u003cbr\u003eTest #2 \u003cbr\u003e5 3 \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003eOutput\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cfont face\u003d\"Courier New\"\u003e\u003c/font\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cpre\u003e\u003c/pre\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003eTest #1 \u003cbr\u003e3 \u003cbr\u003e \u003cbr\u003eTest #2 \u003cbr\u003e2 \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"left\"\u003e\u003cbr\u003e\u003cb\u003eNote\u003c/b\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003eSee picture: \u003cbr\u003e\u003cimg src\u003d\"CDN_BASE_URL/d500786e59f92fafb7e4c6001f341b95?v\u003d1715982494\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"right\"\u003e \u003c/div\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003cdiv align\u003d\"right\"\u003e \u003c/div\u003e\u003c/div\u003e\u003cdiv align\u003d\"left\"\u003e\u003chr\u003e\u003c/div\u003e\u003ctable align\u003d\"left\" cellspacing\u003d\"7\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003eAuthor:\u003c/td\u003e\u003ctd\u003eSergey Simonchik \u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003eResource:\u003c/td\u003e\u003ctd\u003ePetrozavodsk Summer Training Sessions 2004 \u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003eDate:\u003c/td\u003e\u003ctd\u003eAugust 25, 2004 \u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003c/div\u003e \u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\r\n\u003c/div\u003e"}}]}