Solution
Solution 1
If we have points (p,q) and (r,s) and we want to find (u,v) so (r,s) is the midpoint of (u,v) and (p,q), then u=2r−p and v=2s−q. So we start with the point they gave us and work backwards. We make sure all the coordinates stay within the triangle. We have
Pn−1=(xn−1,yn−1)=(2xnmod560, 2ynmod420)
Then P7=(14,92), so x7=14 and y7=92, and we get
nxnyn71492628184556368411231632242122448413368
So the answer is 344.
Solution 2
Let L1 be the nth roll that directly influences Pn+1.
Note that P7=2…22P1+L1+L2+⋯=64(k,m)+64L1+32L2+16L3+8L4+4L5+2L6=(14,92).
Then quickly checking each addend from the right to the left, we have the following information (remembering that if a point must be (0,0), we can just ignore it!):
for 2L6,4L5, since all addends are nonnegative, a non-(0,0) value will result in a x or y value greater than 14 or 92, respectively, and we can ignore them,
for 8L4,16L3,32L2 in a similar way, (0,0) and (0,420) are the only possibilities,
and for 64L1, all three work.
Also, to be in the triangle, 0≤k≤560 and 0≤m≤420.
Since L1 is the only point that can possibly influence the x coordinate other than P1, we look at that first.
If L1=(0,0), then k=26⋅14=64⋅14>40⋅14=560,
so it can only be that L1=(560,0), and k+560=26⋅14
⟹k=64⋅14−40⋅14=24⋅14=6⋅56=336.
Now, considering the y coordinate, note that if any of L2,L3,L4 are (0,0) (L2 would influence the least, so we test that),
then 32L2+16L3+8L4<16420+8420=79±ϵ<80,
which would mean that P1>26⋅(92−80)=64⋅12>42⋅10=420≥m, so L2,L3,L4=(0,420),
and now 64P1+25420+24420+23420=92
⟹P1
=64⋅92−420(2+4+8)
=64⋅92−420⋅14=64(100−8)−142⋅30
=6400−512−(200−4)⋅30
=6400−512−6000+120
=−112+120
=8,
and finally, k+m=336+8=344.