Find the number of congruent triangles?

Say I have a square from (0,0) to (z,z). 
Given a triangle within this square which has integer coordinates 
for all its vertices.
Find out the number of  triangles within this square which are 
congruent to this triangle and have integer coordinates. 
My algorithm is as follows--


 1) Find out the minimum bounding rectangle(MBR) for the given triangle.
 2) Find out the number of congruent triangles, y within that MBR,
    obtained after reflection, rotation of the given triangle. 
    y can be either 2,4 or 8.
 3) Now find out how many such MBR can be drawn within the given 
    big square, say x;
    (This is similar to finding number of squares on a chess board)
 4) x*y is the required answer.

Am I counting several triangles more than once or am I missing something with this algorithm? Is this an online judge problem? This gives me the wrong answer. I thought a lot about it, but I can’t understand it.

+3
source share
3 answers

The approach you are describing is pretty close, but will not count all the congruent triangles in the grid.

The most significant omission is due to the fact that there are turns that retain integer coordinates, but not multiples of 90 degrees.

(0,0), (240,0) (240 180). (3/5) 37 , (0,0), (192,144), (84,288).

, , .

, , NxN, O (N 3) .

P = (x, y)

T (p, q, r) - , p, q r.

T (q, r, p), T (r, p, q), T (p, r, q) ,

p < q < r

- .

p < q :

((p.y < q.y) OR ((p.y = p.y) AND (p.x < q.x)).

T1 = (A, B, C) T2 = (P, Q, R), T1 T2 , , f:

|AB| = |PQ|,
|BC| = |QR|, and 
|CA| = |RP|.

, .

AB, A (0,0), A < | AB | 2= L.

( , sqrt (L) O (N), NxN sqrt (2) * N).

B (x, y)

(0,0), 
(0,ceil(sqrt(L)), and 
(ceil(sqrt(L), ceil(sqrt(L))

| AB | 2 O (N 2), 4 :

B = (x, y) x = 0, , (0, -y) (0, y),

A < .

x = y x > 0, A < (-x, y) , , (-x, y) B.

y < x x > 0, (y, x), (-x, y) (-y, x) .

O (N 2), O (N) . ( sqrt (L) 2 * pi * sqrt (L) , .)

AB, A < B | AB | 2= L. B, L, .

(A, B, C), A B, , | AB |. C O (1) , , | AC |, B | BC |. ( , . , A < B < C. , , 0,5 .)

, (A, B, C) O (N) O (1), O (N).

, , , scalene, 1, 3 6 (A, B, C), , A < B < C A . , - O (N).

(, , , sqrt (2) * N ​​ X). , , , . , O (N) . A, , O (N).

, A . O (N 2) A, A = (x, y), O (N) , (x, y) A, B C "origin". O (1), , A, B, C - NxN, , , . O (N 3), .

289x289, A = (0,0), B = (240,0) C = (240 180). Z (0,0).

| AB | 2 - 57600. | BC | 2 - 32400. | CA | 2 - 90000.

B L = r 2= 57600 Z Z < B:

(140, 0), (144, 192), (192, 144), (-144, 192), (-192, 144)

C L = 32400 Z < C:

(110, 144), (-108, 144), (-144, 108)

A L = 90000 Z < A:

(84, 288), (288, 84), (-84, 288), (-288, 84), (180, 240), (240, 180), (-180, 240), (-240, 180).

, , 6 :

(0, 0),(-180, 240),(0, 240)   L= 90000 32400 57600
(0, 0),(0, 240),(180, 240)    L= 57600 32400 90000
(0, 0),(240, 0),(240, 180)    L= 57600 32400 90000
(0, 0),(192, 144),(84, 288)   L= 57600 32400 90000
(0, 0),(-192, 144),(-84, 288) L= 57600 32400 90000
(0, 0),(240, 0),(0, 180)      L= 57600 90000 32400
(0, 0),(0, 180),(240, 180)    L= 32400 57600 90000
(0, 0),(180, 0),(180, 240)    L= 32400 57600 90000
(0, 0),(108, 144),(-84, 288)  L= 32400 57600 90000
(0, 0),(-108, 144),(84, 288)  L= 32400 57600 90000
(0, 0),(180, 0),(0, 240)      L= 32400 90000 57600
(0, 0),(144, 108),(-144, 192) L= 32400 90000 57600
(0, 0),(-144, 108),(144, 192) L= 32400 90000 57600
(0, 0),(-240, 180),(0, 180)   L= 90000 57600 32400
(0, 0),(288, 84),(144, 192)   L= 90000 32400 57600
(0, 0),(-288, 84),(-144, 192) L= 90000 32400 57600
(0, 0),(-180, 240),(0, 240)   L= 90000 32400 57600

289x289 , 43504 .

:

(0, 0),(0, 240),(180, 240)  L= 57600 32400 90000
(0, 0),(240, 0),(240, 180)  L= 57600 32400 90000
(0, 0),(192, 144),(84, 288) L= 57600 32400 90000
(0, 0),(240, 0),(0, 180)    L= 57600 90000 32400
(0, 0),(0, 180),(240, 180)  L= 32400 57600 90000
(0, 0),(180, 0),(180, 240)  L= 32400 57600 90000
(0, 0),(180, 0),(0, 240)    L= 32400 90000 57600
(0, 0),(288, 84),(144, 192) L= 90000 32400 57600
(0, 1),(0, 241),(180, 241)  L= 57600 32400 90000
(0, 1),(240, 1),(240, 181)  L= 57600 32400 90000
(0, 1),(240, 1),(0, 181)    L= 57600 90000 32400

:

(288, 94),(0, 178),(144, 286)  L= 90000 32400 57600
(288, 95),(48, 275),(288, 275) L= 90000 57600 32400
(288, 95),(0, 179),(144, 287)  L= 90000 32400 57600
(288, 96),(48, 276),(288, 276) L= 90000 57600 32400
(288, 96),(0, 180),(144, 288)  L= 90000 32400 57600
(288, 97),(48, 277),(288, 277) L= 90000 57600 32400
(288, 98),(48, 278),(288, 278) L= 90000 57600 32400
(288, 99),(48, 279),(288, 279) L= 90000 57600 32400
(288, 100),(48, 280),(288, 280) L= 90000 57600 32400
(288, 101),(48, 281),(288, 281) L= 90000 57600 32400
(288, 102),(48, 282),(288, 282) L= 90000 57600 32400
(288, 103),(48, 283),(288, 283) L= 90000 57600 32400
(288, 104),(48, 284),(288, 284) L= 90000 57600 32400
(288, 105),(48, 285),(288, 285) L= 90000 57600 32400
(288, 106),(48, 286),(288, 286) L= 90000 57600 32400
(288, 107),(48, 287),(288, 287) L= 90000 57600 32400
(288, 108),(48, 288),(288, 288) L= 90000 57600 32400

289x289.

+7

, . , , . , , , , 8 .

. . , , , , , . , , , , , 2 3 .

+2

?

"" , , MBR - :

  • there may be triangles that cross the boundaries of the MBR
  • there may be triangles with integer coordinates with an increase not equal to an integer (i.e., through rotation. This is a theory (because I have no example in my hands), but we must quote that this is wrong before we go forward)

If you want to know that grade than MBR is good enough

+1
source

Source: https://habr.com/ru/post/1719250/


All Articles