Fading Coder

One Final Commit for the Last Sprint

Codeforces Round 876 (Div. 2) Solutions

A. The Good Array Tags: greedy, math Problem: For any (i \in {1,2,\dots,n}), the array (a) must have at least (\lceil \frac{i}{k} \rceil) ones among its first (i) elements and also atleast (\lceil \frac{i}{k} \rceil) ones among its last (i) elements. Solution: Special case (k=1): The positions where...

Constructing an n for Linear Congruence gcd(an+b, c)=1

A solution exists for the equation (\gcd(an+b, c) = 1) if and only if (\gcd(a, b, c) = 1). If (\gcd(a, b, c) > 1), the problem has no solution and (-1) is output. Given the condition (\gcd(a, b, c) = 1), we can construct a valid (n). Let (x = \gcd(b, c)). If (x = 1), then (n = 0) satisfies (\gcd(...