Angular Bisector and Tangent
Given an integer-sided triangle ABC with BC <= AC <= AB, let: k be the angular bisector of angle ACB, m be the tangent at C to the circumscribed circle of ABC, n be the line through B parallel to m...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Given is an integer sided triangle \(ABC\) with \(BC \le AC \le AB\).
\(k\) is the angular bisector of angle \(ACB\).
\(m\) is the tangent at \(C\) to the circumscribed circle of \(ABC\).
\(n\) is a line parallel to \(m\) through \(B\).
The intersection of \(n\) and \(k\) is called \(E\).

How many triangles \(ABC\) with a perimeter not exceeding \(100\,000\) exist such that \(BE\) has integral length?
Problem 296: Angular Bisector and Tangent
Mathematical Foundation
Theorem 1 (Formula for ). Let , , with . Then
Proof. By the tangent-chord angle theorem (also known as the inscribed angle theorem for tangent lines), the angle between the tangent at and the chord equals the inscribed angle , and the angle between and chord equals .
Let . The bisector bisects , making angles with both and . The line through is parallel to .
In triangle , since , the angle between and equals the angle between and (alternate interior angles with the transversal … more precisely, corresponding angles via the parallel). The bisector from makes angle with .
Applying the sine rule in triangle :
Since the angles of triangle sum to , and using , , we get . By the sine rule in the original triangle, , and after algebraic manipulation (using and the identity ), one obtains:
Theorem 2 (Integrality Condition). Let , , with . Then if and only if .
Proof. We have . Since , we have . Therefore if and only if .
Lemma 1 (Parametric Constraints). Writing for some positive integer , the constraints are:
- Ordering: gives ; gives .
- Triangle inequality: gives , hence .
- Perimeter: .
Proof. Substituting , , :
- (since ).
- , i.e., .
- .
- Perimeter .
Editorial
Triangle ABC with integer sides a=BC <= b=AC <= c=AB, perimeter <= 100000. BE = ca / (a+b) must be a positive integer. With g = gcd(a,b), a = ga’, b = gb’, gcd(a’,b’)=1: BE = ca’/(a’+b’), so (a’+b’) | c, i.e., c = k*(a’+b’). Constraints: a’ <= b’ (from a <= b) k >= ceil(gb’/(a’+b’)) (from b <= c) k < g (from triangle inequality a+b > c) (g+k)(a’+b’) <= P (perimeter). We enumerate coprime pairs (a’, b’) with 1 <= a’ <= b’. Finally, iterate over each g: k ranges from ceil(g*b’/s) to min(g-1, floor(P/s) - g).
Pseudocode
Enumerate coprime pairs (a', b') with 1 <= a' <= b'
For each g: k ranges from ceil(g*b'/s) to min(g-1, floor(P/s) - g)
Complexity Analysis
- Time: where and counts coprime pairs summing to . By standard estimates this is .
- Space: working memory (no auxiliary data structures beyond loop variables).
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
// Problem 296: Angular Bisector and Tangent
//
// Triangle ABC with integer sides a=BC <= b=AC <= c=AB, perimeter <= 100000.
// BE = c*a / (a+b) must be a positive integer.
//
// Let g = gcd(a,b), a = g*a', b = g*b', gcd(a',b')=1.
// Then BE = c*a'/(a'+b'), and since gcd(a',a'+b')=1, we need (a'+b') | c.
// So c = k*(a'+b') for positive integer k.
//
// Constraints:
// a <= b: a' <= b'
// b <= c: g*b' <= k*(a'+b') => k >= ceil(g*b'/(a'+b'))
// a+b > c: g*(a'+b') > k*(a'+b') => k < g
// perimeter <= P: (g+k)*(a'+b') <= P
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
const long long P = 100000;
long long count = 0;
// Iterate over coprime (a', b') with 1 <= a' <= b'
// s = a' + b', s ranges from 2 (a'=b'=1) upward
// Need (g+k)*s <= P, g >= 2 (since k >= 1, k < g => g >= 2), so s <= P/2
for (long long bp = 1; bp * 2 + 1 <= P; bp++) {
// a' ranges from 1 to b'
for (long long ap = 1; ap <= bp; ap++) {
if (__gcd(ap, bp) != 1) continue;
long long s = ap + bp;
// g ranges from 2 to floor(P/s) - 1 (need k >= 1, so g+1 <= P/s => g <= P/s - 1)
// Also k < g and k >= ceil(g*b'/s)
long long max_gs = P / s; // (g+k)*s <= P, g+k <= P/s
for (long long g = 2; g <= max_gs - 1; g++) {
// k >= ceil(g*b'/s), k < g, g+k <= P/s => k <= P/s - g
long long k_min = (g * bp + s - 1) / s; // ceil(g*bp/s)
long long k_max = min(g - 1, max_gs - g);
if (k_min > k_max) continue;
count += k_max - k_min + 1;
}
}
}
cout << count << endl;
return 0;
}
"""
Project Euler Problem 296: Angular Bisector and Tangent
Triangle ABC with integer sides a=BC <= b=AC <= c=AB, perimeter <= 100000.
BE = c*a / (a+b) must be a positive integer.
With g = gcd(a,b), a = g*a', b = g*b', gcd(a',b')=1:
BE = c*a'/(a'+b'), so (a'+b') | c, i.e., c = k*(a'+b').
Constraints:
a' <= b' (from a <= b)
k >= ceil(g*b'/(a'+b')) (from b <= c)
k < g (from triangle inequality a+b > c)
(g+k)*(a'+b') <= P (perimeter)
"""
from math import gcd
def solve():
P = 100000
count = 0
for bp in range(1, P // 2 + 1):
if (bp + 1) * 2 > P:
break
for ap in range(1, bp + 1):
if gcd(ap, bp) != 1:
continue
s = ap + bp
if s * 2 > P:
break
max_gs = P // s # g + k <= max_gs
for g in range(2, max_gs):
k_min = (g * bp + s - 1) // s # ceil(g*bp/s)
k_max = min(g - 1, max_gs - g)
if k_min > k_max:
continue
count += k_max - k_min + 1
print(count)
if __name__ == "__main__":
solve()