Solution Set for the 2023 SMU RoboCom-CAIP Selection Contest

Problem A: Maximum Value Boundary Analysis In this problem, we need to calculate the sum of counts $f(k)$ for pairs $(i, j)$ that satisfy specific boundary conditions related to two arrays $A$ and $B$. Let $f(k)$ represent the number of valid pairs where the second index $j$ equals $k$. We define $last\_k$ as the index where the maximum value o ...

Posted on Fri, 04 Sep 2026 16:45:03 +0000 by dhaselho

Optimizing Array Operations for GCD and Median Calculations

GCD Optimization in Array Processing When working with arrays, selecting the minimum element first often leads to optimal solutions for GCD-based problems. Consider an array where each element's GCD with previous selections contributes to the total sum. The optimal approach involves: Sorting the array and selecting the smallest element first C ...

Posted on Wed, 02 Sep 2026 16:18:34 +0000 by Delaran

Weighted Round Robin Load Balancing in PHP

Weighted Round Robin (WRR) is a load-balancing algorithm that distributes requests among servers based on assigned weights. Servers with higher weights receive more traffic proportionally. This implementation uses an efficient approach leveraging the greatest common divisor (GCD) of all weights to minimize unnecessary iterations. The core idea ...

Posted on Wed, 02 Sep 2026 16:13:26 +0000 by bigwatercar

Counting GCD Values in Range Using Integer Division Block

Given integers l, r, and k, determine how many distinct greatest common divisors (GCDs) can be formed by selecting any k numbers from the range [l, r]. The constraint is: 1 ≤ l ≤ r ≤ 10^12, 2 ≤ k ≤ r - l + 1. Rather than computing all possible GCD values directly, we count all potential divisors. Any integer m = i × j that divides two numbers x ...

Posted on Thu, 27 Aug 2026 16:53:21 +0000 by AMCH

Dynamic Programming Solutions for Three Algorithmic Problems

Ehab and the Expected GCD Problem The key insight is that the first element should have the maximum number of prime factors, and subsequent elements should remove at most one prime factor per step for optimality. The smallest prime factors are 2 and 3, and using 3 more than once is suboptimal (e.g., 5 can be replaced by 2² for better results). ...

Posted on Fri, 17 Jul 2026 17:02:09 +0000 by RossC0

Algorithm Solutions for Competitive Programming Problems

Modular Division of Large Numbers This solution demonstrates how to perform division operations with large numbers under a specific modulus using Fermat's Little Theorem. The approach converts string representations of numbers into numerical arrays and applies modular arithmetic properties. #include <iostream> #include <cstdio> #inc ...

Posted on Tue, 14 Jul 2026 17:29:01 +0000 by modcar

Fraction and Complex Number Class Implementation with Operator Overloading

Fraction Class with Addition Operator Define a class Rational to represent fractoins using two private integer members: numerator and denominator. The denominator is always positive, witth the sign of the fraction determined solely by the numerator. Implement operator overloading for addition (+) to sum two fractions and return the result in it ...

Posted on Wed, 24 Jun 2026 18:29:13 +0000 by jenp

AtCoder Beginner Contest 060 - Problem Solutions

Given three strings A, B, and C, determine whether the last character of A matches the first character of B, and the last character of B matches the first character of C. Each string consists of lowercase letters and is provided on a single line separated by spaces. Solution Approach: Extract the relevant characters and perform two comparisons. ...

Posted on Wed, 24 Jun 2026 16:26:26 +0000 by fiddlehead_cons

Optimizing String Construction and GCD Generation for Competitive Programming

To maximizee the number of positive votes, we can separate reviews into two groups: one for negative ratings (value 2) and another for all others. Since negative reviews contribute nothing to the total, we simply count all non-negatvie ratings. #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); ...

Posted on Sat, 06 Jun 2026 16:47:02 +0000 by plasmahba

Solution: PAROVI - Counting Segment Coverings with Coprime Pairs

Problem Analysis Given (n) where (1 \le n \le 20), we need to count the number of ways to completely cover the interval ([1, n]) using segments where each segment connects two coprime numbers. First, preprocess all coprime pairs ({a, b}) where (\gcd(a, b) = 1) and (a < b). Note that ({1, 1}) is excluded. When (n = 20), there are exactly 127 ...

Posted on Wed, 13 May 2026 01:48:40 +0000 by Erik-NA