Problem Link:
CONTEST
PRACTICE
Author- Virender Yadav
Tester- Vipin Khushu
Editorialist- Virender Yadav
Difficulty:
Simple
Prerequisites:
Math
Problem:
We have to find out that Is bishop can take down the pawn or not?
Explanation:
As we know Bishop can attacks at 45,135,225,315 degree angles only . First get the position accoring to x-axis and y-axis in chessboard.
As pawn can be attacked with bishop when both bishop and pawn are in such positions that the slop obtained from their positions is equal to tangent of 45 degree or 135 degree or 225 degree or 315 degree.
Check the slope if it comes out equal to any of the above angles print “true” else print “false”
Solution:
http://ideone.com/Xs9kDR