Archive

Posts Tagged ‘Geometry’

Project Euler – Problem 264

July 28, 2017 Leave a comment

Today I managed to solve problem 264 from Project Euler. This is my highest rating problem until now: 85%. You can click the link for the full text of the problem. The main idea is to find all triangles ABC with vertices having integer coordinates such that

  • the circumcenter O of each of the triangles is the origin
  • the orthocenter H (the intersection of the heights) is the point of coordinates (0,5)
  • the perimeter is lower than a certain bound

I will not give detailed advice or codes. You can already find a program online for this problem (I won’t tell you where) and it can serve to verify the final code, before going for the final result. Anyway, following the hints below may help you get to a solution.

The initial idea has to do with a geometric relation linking the points A, B, C, O and H. Anyone who did some problems with vectors and triangles should have come across the needed relation at some time. If not, just search for important lines in triangles, especially the line passing through O and H (and another important point).

Once you find this vectorial relation, it is possible to translate it in coordinates. The fact that points A, B, C are on a circle centered in O shows that their coordinates satisfy an equation of the form x^2+y^2=n, where n is a positive integer, not necessarily a square… It is possible to enumerate all solutions to the following equation for fixed n, simply by looping over x and y. This helps you find all lattice points on the circle of radius \sqrt{n}.

Once these lattice points are found one needs to check the orthocenter condition. The relations are pretty simple and in the end we have two conditions to check for the sum of the x and y coordinates. The testing procedure is a triple loop. We initially have a list of points on a circle, from the previous step. We loop over them such that we dont count triangles twice: i from 1 to m, j from i+1 to m, k from j+1 to m, etc. Once a suitable solution is found, we compute the perimeter using the classical distance formula between two points given in coordinates. Once the perimeter is computed we add it to the total.

Since the triple loop has cubic complexity, one could turn it in a double loop. Loop over pairs and construct the third point using the orthocenter condition. Then just check if the point is also on the circle. I didn’t manage to make this double loop without overcounting things, so I use it as a test: use double loops to check every family of points on a given circle. If you find something then use a triple loop to count it properly. It turns out that cases where the triple loop is needed are quite rare.

So now you have the ingredients to check if on a circle of given radius there are triangles with the desired properties. Now we just iterate over the square of the radius. The problem is to find the proper upper bound for this radius in order to get all the triangles with perimeter below the bound. It turns out that a simple observation can get you close to a near optimal bound. Since in the end the radii get really large and the size of the triangles gets really large, the segment OH becomes small, being of fixed length 5. When OH is very small, the triangle is almost equilateral. Just use the upper bound for the radius for an equilateral triangle of perimeter equal to the upper bound of 100000 given in the problem.

Using these ideas you can build a bruteforce algorithm. Plotting the values of the radii which give valid triangles will help you find that you only need to loop over a small part of the radii values. Factoring these values will help you reduce even more the search space. I managed to  solve the problem in about 5 hours in Pari GP. This means things could be improved. However, having an algorithm which can give the result in “reasonable” time is fine by me.

I hope this will help you get towards the result.

Advertisements

Balkan Mathematical Olympiad 2017 – Problems

May 10, 2017 Leave a comment

Problem 1. Find all ordered pairs of positive integers { (x, y)} such that:

\displaystyle x^3+y^3=x^2+42xy+y^2.

Problem 2. Consider an acute-angled triangle {ABC} with {AB<AC} and let {\omega} be its circumscribed circle. Let {t_B} and {t_C} be the tangents to the circle {\omega} at points {B} and {C}, respectively, and let {L} be their intersection. The straight line passing through the point {B} and parallel to {AC} intersects {t_C} in point {D}. The straight line passing through the point {C} and parallel to {AB} intersects {t_B} in point {E}. The circumcircle of the triangle {BDC} intersects {AC} in {T}, where {T} is located between {A} and {C}. The circumcircle of the triangle {BEC} intersects the line {AB} (or its extension) in {S}, where {B} is located between {S} and {A}.

Prove that {ST}, {AL}, and {BC} are concurrent.

Problem 3. Let {\mathbb{N}} denote the set of positive integers. Find all functions {f:\mathbb{N}\longrightarrow\mathbb{N}} such that

\displaystyle n+f(m)\mid f(n)+nf(m)

for all {m,n\in \mathbb{N}}

Problem 4. On a circular table sit {\displaystyle {n> 2}} students. First, each student has just one candy. At each step, each student chooses one of the following actions:

  • (A) Gives a candy to the student sitting on his left or to the student sitting on his right.
  • (B) Separates all its candies in two, possibly empty, sets and gives one set to the student sitting on his left and the other to the student sitting on his right.

At each step, students perform the actions they have chosen at the same time. A distribution of candy is called legitimate if it can occur after a finite number of steps. Find the number of legitimate distributions.

(Two distributions are different if there is a student who has a different number of candy in each of these distributions.)

Source: AoPS

Project Euler Problem 144 – Laser light escaping an ellipse

February 5, 2017 Leave a comment

ellipse

Project Euler – problem 144 – visualization of the solution in Matlab

Some of the easy Putnam 2016 Problems

December 11, 2016 Leave a comment

Here are a few of the problems of the Putnam 2016 contest. I choose to only list problems which I managed to solve. Most of them are pretty straightforward, so maybe the solutions posted here may be very similar to the official ones. You can find a complete list of the problems on other sites, for example here.

A1. Find the smallest integer {j} such that for every polynomial {p} with integer coefficients and every integer {k}, the number

\displaystyle p^{(j)}(k),

that is the {j}-th derivative of {p} evaluated at {k}, is divisible by {2016}.

Hints. Successive derivatives give rise to terms containing products of consecutive numbers. The product of {j} consecutive numbers is divisible by {j!}. Find the smallest number such that {2016 | j!}. Prove that {j-1} does not work by choosing {p = x^{j-1}}. Prove that {j} works by working only on monomials…

Read more…

IMO 2016 – Problem 1

July 26, 2016 Leave a comment

IMO 2016, Problem 1. Triangle {BCF} has a right angle at {B}. Let {A} be the point on line {CF} such that {FA=FB} and {F} lies between {A} and {C}. Point {D} is chosen such that {DA=DC} and {AC} is the bisector of {\angle DAB}. Point {E} is chosen such that {EA=ED} and {AD} is the bisector of {\angle EAC}. Let {M} be the midpoint of {CF}. Let {X} be the point such that {AMXE} is a parallelogram (where {AM || EX} and {AE || MX}). Prove that the lines {BD, FX} and {ME} are concurrent.

Read more…

Balkan Mathematical Olympiad – 2016 Problems

Problem 1. Find all injective functions {f: \mathbb R \rightarrow \mathbb R} such that for every real number {x} and every positive integer {n},

\displaystyle \left|\sum_{i=1}^n i\left(f(x+i+1)-f(f(x+i))\right)\right|<2016

Problem 2. Let {ABCD} be a cyclic quadrilateral with {AB<CD}. The diagonals intersect at the point {F} and lines {AD} and {BC} intersect at the point {E}. Let {K} and {L} be the orthogonal projections of {F} onto lines {AD} and {BC} respectively, and let {M}, {S} and {T} be the midpoints of {EF}, {CF} and {DF} respectively. Prove that the second intersection point of the circumcircles of triangles {MKT} and {MLS} lies on the segment {CD}.

Problem 3. Find all monic polynomials {f} with integer coefficients satisfying the following condition: there exists a positive integer {N} such that {p} divides {2(f(p)!)+1} for every prime {p>N} for which {f(p)} is a positive integer.

Problem 4. The plane is divided into squares by two sets of parallel lines, forming an infinite grid. Each unit square is coloured with one of {1201} colours so that no rectangle with perimeter {100} contains two squares of the same colour. Show that no rectangle of size {1\times1201} or {1201\times1} contains two squares of the same colour.

Optimal triangles with vertices on fixed circles

October 5, 2015 Leave a comment

Let {x,y,z>0} and suppose {ABC} is a triangle such that there exists a point {O} which satisfies {OA=x}, {OB = y}, {OC = z}. What is the relative position of {O} with respect to the triangle {ABC} such that

a) The area is maximized;

b) The perimeter is maximized.

This was inspired by this answer on Math Overflow.

Read more…

%d bloggers like this: