Блог пользователя StellarSpecter

Автор StellarSpecter, история, 5 месяцев назад, По-английски

I solved it as if y<0 and abs(y) >= abs(x) cout<<"NO"<<endl;

But this did not work even after trying so long.

why is this incorrect can anyone help this newbie?

THANKS!

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

»
5 месяцев назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

It's the simplest. Just run loops EASY PEASY

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The $$$x$$$ never moves. You can always reach it in a finite number of moves. Only the $$$y$$$ does.

»
5 месяцев назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

If y = -1, you move first and can therefor still reach it, as you'll be at -1 before it moves. You can move diagonally, so as long as y is greater than -1 you can reach it. Since regardless of the X, you can still move downwards at the same time as going to some side.

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The basic idea is this: As x remains unchanged for the point under discussion: We try to reach x, and just to offset the fall, just assume we also go down every second. So, we move (1 right + 1 down) or (1 left + 1 down) depending on x. Now, after abs(x) moves, we reach x with y coordinate -abs(x). By this time, the coin is at y-coordinate: y_initial — abs(x) + 1. So, if the y-coordinate of the coin is above that of ours, we are through! Else, not. Note that this won't give the minimum moves, but just tells whether the situation is feasible or not.