Solving Math and Graph Problems from a Competitive Programming Contest
Problem 1: Counting Valid Pairs with LCM Condition
Problem Description
Given an integer n where 1 ≤ n ≤ 10^8, determine the number of pairs (x, y) such that 1 ≤ x, y ≤ n and the following inequality holds:
lcm(x, y) / gcd(x, y) ≤ 3
Note that lcm(x, y) = (x * y) / gcd(x, y)^2.
Solution Approach
This is a straightforward number theory problem. L ...
Posted on Mon, 10 Aug 2026 16:39:42 +0000 by HaVoC