| ||
|
3765: Chain of Fools
Time Limit(Common/Java):1000MS/3000MS
Memory Limit:65536KByte Total Submit: 23 Accepted:6 Description
Many of you have heard the story of Turing's bicycle: Seems the sprocket on the crank of the bicycle had a broken prong. Also his chain had one link that was bent. When the bent link on the chain came to hook up with the broken prong, the chain would fall off and Turing would stop and put the chain back on. But Turing, being who he was, could predict just when this was going to happen—meaning he would know how many pedal strokes it would be—and so would hop off his bike just before it happened and gently move the pedals by hand as the undesired coupling passed. Then he'd be merrily (we imagine) on his way. (A picture of the sprocket-chain set up is shown below.)
Input
Input for each test case will be one line of the form s c p l, where s is the number of prongs on the front sprocket (1 < s < 100) , c is the number of links in the chain (200 > c > s), p is the initial position of the broken prong, and l is the initial position of the bent link. The line 0 0 0 0 will follow the last line of input. Output
For each test case output a single one line as follows: Sample Input Sample Output Source East Central North America Regional 2011 Uploader |
[Submit] [Status] |