Number Theory Min-Max Inclusion-Exclusion The core identities for min-max inclusion-exclusion over finite sets are: $$\max(S) = \sum_{T \subseteq S} (-1)^{|T|+1} \min(T)$$ $$\min(S) = \sum_{T \subseteq S} (-1)^{|T|+1} \max(T)$$ Expanding the summation shows all non-extremal values cancel out. The id...
Multiple Choice Questions Question 1 In 8-bit two's complement representation, the binary number 10101011 corresponds to which decimal value? Options: A. 43 B. -85 C. -43 D. -84 Answer: B Explanation: The most significnat bit indicates negativity. Covnerting from two's complement yields -85. Questio...
We consider an undirected graph with (n) nodes and (m) weighted edges. The task is to select edges that connect all nodes in a tree-like fashion, but the cost rule differs from a standard minimum spanning tree. When an edge with weight (w) is added between a node already placed at depth (d) and a ne...
Problem Background A long highway connects City B and City T, with existing road signs placed at certain points. Drivers often find the distance between consecutive signs too large. To quantify this issue, we define the "empty index" of the highway as the maximum distance between any two a...
Sexagenary Cycle Offset Calculation Converting between Chinese sexagenary cycle notation and absolute year values involves identifying positions with in the 60-year cycle. The cycle combines ten celestial stems with twelve terrestrial branches. Given a target designation composed of one stem and one...
Basic Data Type Conversion Converting character literals to their integer Unicode values is a frequent requirement in competitive environments. Direct casting provides an efficient mechanism for this operation. public class AsciiConversion { public static void main(String[] args) { char target = 'L'...
This is a curated list of algorithm thinking problems, focusing on those with minimal code complexity but requiring creative problem-solving. Problems marked with (!) are foundational examples, while (*) denote highly insightful problems that build problem-solving intuition. Updates will be made per...
"Little by little, a little becomes a lot; grain by grain, a heap is formed. Seconds may be short, yet they compose the great eras of eternity. — Fletcher" Key Topics Covered 1. Depth-First Search (DFS) Fibonacci Triple Sum Problem Problem Description: Given an integer t test cases, for e...
A - What month is it? A straightforward problem. The solution is to output ((x + y - 1) \mod 12 + 1). B - Most Mniority This problem can be solved with a brute-force approach. First, for each vote, count the number of votes for each option. Then, iterate through all participants and increment a coun...
A. Dual Trigger (Thinking Problem) Problem Statement We have n lamps numbered 1 to n arranged in a row, all off initially. You can perform any number of operations (including zero): Choose two non-adjacent unlit lamps, and turn both on. Given a target configuration s where s_i = 1 means lamp i is on...