The Gateway to Computer Science Excellence
+8 votes

Imagine the first quadrant of the real plane as consisting of unit squares. A typical square has $4$ corners: $(i, j), (i+1, j), (i+1, j+1),$and $(i, j+1)$, where $(i, j)$ is a pair of non-negative integers. Suppose a line segment $l$ connecting $(0, 0)$ to $(90, 1100)$ is drawn. We say that $l$ passes through a unit square if it passes through a point in the interior of the square. How many unit squares does $l$ pass through?

  1. $98,990$
  2. $9,900$
  3. $1,190$
  4. $1,180$
  5. $1,010$
in Numerical Ability by Boss (30.7k points) | 702 views
explain it please

2 Answers

+10 votes
Best answer

Answer will be (d) 1,180

If a line segment passes through unit square from $(0,0)$ to $(i,j)$ the line intersects $(i+j-gcd(i,j))$

no. of squares =$ (90+1100-10)=1180.$

by Veteran (118k points)
edited by

@srestha Apart from the below stackexchange link, you do have any standard reference explaining the formulae you have used to answer?

My logic yields $1170$ as the number of units the given line passes through. Please check my logic.

Slope of the line connecting $(0, 0) \text{ and } (90, 1100) = \frac{1100-0}{90-0} = 12.22...$

This means, per $1$ unit of the x-axis, the line passes through $13$ units across the y-axis.

$\therefore$ The line passes through $13 \times 90 = 1170$ unit squares. 

0 votes

I think (B) answer will be 99000

(0,0) to(90,1100) total rowwise 91 points and columnwise 1101 points

Each 2 points makes 1 square

So, total no. of unit square are 90* 1100 = 99000 

by Veteran (118k points)
Ans given is d) option. I think 99000 will be total no. of unit squares from point (0,0) to (90,1100) but we have to calculate only the ones through which this line passes.

I think there is no harm if line goes like this and condition also satisfies

as there is no specification about line

I think then it would become a curve instead of line segment... Also the ans still remains to be 1180..
yes u have to put formula for doing this

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,741 questions
57,251 answers
104,684 users