# https://[Log in to view URL]
r, x, y, vx, vy, t = [*map(int, input().split())]
c = 0
visited = set()
path = []
while c < t:
    if (x, y, vx, vy) in visited:
        xx, yy = path[t % len(path)]
        print(xx, yy, 0)
        exit()
    visited.add((x, y, vx, vy))
    path.append((x, y))

    x += vx
    y += vy
    vx += -1 if x > 0 else 1 if x < 0 else 0
    vy += -1 if y > 0 else 1 if y < 0 else 0
    c += 1
    if max(abs(x), abs(y)) <= r:
        print(x, y, 1)
        exit()
print(x, y, 0)
    
        

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: