题意:
In one one-dimensional world there are n platforms. Platform with index k (platforms are numbered from 1) is a segment with coordinates[(k - 1)m, (k - 1)m + l], and l < m. Grasshopper Bob starts to jump along the platforms from point 0, with each jump he moves exactlyd units right. Find out the coordinate of the point, where Bob will fall down. The grasshopper falls down, if he finds himself not on the platform, but if he finds himself on the edge of the platform, he doesn't fall down.
找到第一个FALL DOWN的位置
思路:
暴力,但可能会出现"循环"【一直不会FALL DOWN,直到超出第N个PLATFORM】。则循环一定是又跳到0。即D%M==0的第一个位置。
代码:
ll n,d,m,l; int main(){ cin>>n>>d>>m>>l; ll D=0; for(;;){ ll t=D%m; if(t>l){ print("%I64d ",D); ret 0; } if(D&&D%m==0){ print("%I64d ",((n-1)*m+l)/d*d+d); ret 0; } D+=d; } return 0; }