|
|
back to boardIf the plane fly across a edge and it will produce a point then produce a new block so the answer add one. If gcd(M, N) = 1, it means there is no situation that the plane fly across the crossroads. See from left to right it produce M point and see from north to south it produce N point, but one is calculate twice, so there are M + N - 1 points and Ans is M + N - 1. and what if gcd(m,n)!= 1 ?? Sorry, can't get you and what if gcd(m,n)!= 1 ?? Sorry, can't get you Reduce to smaller problem (m / gcd(m,n), n / gcd(m,n)) and then use it to solve the original problem. |
|
|