brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1263A - Sweet Problem

We are given three piles of candies: red, green, and blue. Each pile has a certain number of candies, represented by integers $r$, $g$, and $b$. Every day, Tanya eats exactly two candies, but they must be of different colors.

codeforcescompetitive-programmingmath
CF 1264F - Beautiful Fibonacci Problem

We are given a small arithmetic sequence of positive integers: $a, a+d, a+2d, dots, a+(n-1)d$. The goal is to find another arithmetic sequence $b, b+e, b+2e, dots, b+(n-1)e$ such that the last 18 digits of the corresponding Fibonacci numbers contain the original numbers as…

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1264B - Beautiful Sequence

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 1265E - Beautiful Mirrors

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingdata-structuresdpmathprobabilities
CF 1265A - Beautiful String

We are given several independent strings, each consisting of the characters a, b, c, and ?. The task is to replace every ? with one of the letters a, b, or c so that the final string has no two equal adjacent characters.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1266B - Dice Tower

The problem asks us to figure out whether it is possible to build a vertical tower of standard six-sided dice such that the sum of all visible pips equals a given integer. We have an unlimited number of dice, and for each die, we can choose its orientation.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1267F - Foolprüf Security

Before I dive into writing the full editorial, I want to clarify one thing: Codeforces Problem 1267F, Foolprüf Security, involves a graph with weighted edges and some combinatorial security constraint.

codeforcescompetitive-programminggraphs
CF 1267A - Apprentice Learning Trajectory

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programming
CF 1267B - Balls of Buma

We are given a row of colored balls represented as a string of uppercase letters. The task is to insert a single ball of any color at any position, including at the ends, so that after the insertion, a chain reaction of eliminations occurs until no segment of length three or…

codeforcescompetitive-programming
CF 1268B - Domino for Young

The Young diagram can be viewed as a histogram whose column heights are given by a non-increasing array $a1,a2,dots,an$.

codeforcescompetitive-programmingdpgreedymath
CF 1269B - Modulo Equality

We have two arrays of equal length. We may choose a single non-negative value x, add it to every element of the first array, and take all results modulo m. After this transformation, the order of elements does not matter.

codeforcescompetitive-programmingbrute-forcesortings
CF 1270A - Card Game

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programminggamesgreedymath
CF 1271F - Divide The Students

Each test case describes a single student group that must be split into two subgroups. Every subgroup has three independent “resource limits”: an auditorium limit for maths attendees, a computer lab limit for programming attendees, and a gym limit for PE attendees.

codeforcescompetitive-programmingbrute-force
CF 1271A - Suits

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingbrute-forcegreedymath
CF 1271C - Shawarma Tent

We are working on a grid where movement is restricted to four directions, so distance between two points is measured using Manhattan distance. A school is fixed at one coordinate, and each student lives at another coordinate on the same infinite grid.

codeforcescompetitive-programmingbrute-forcegeometrygreedyimplementation
CF 1272F - Two Bracket Sequences

We are given two sequences of brackets, s and t, which may individually be invalid as bracket sequences. The task is to produce the shortest string of brackets that is valid (balanced and properly nested) and contains both s and t as subsequences.

codeforcescompetitive-programmingdpstringstwo-pointers
CF 1272C - Yet Another Broken Keyboard

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingcombinatoricsdpimplementation
CF 1275F - Шардирование постов

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programming*specialbinary-searchinteractive
CF 1275B - Code Review

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programming*special
CF 1275C - #define Задача B ...

We are asked to simulate a massive array defined recursively using C-style macros. The macros expand in a very structured way: each macro level quadruples the number of elements generated by the previous level, with simple offsets added.

codeforcescompetitive-programming*special
CF 1276F - Asterisk Substrings

We are given a string s consisting of lowercase English letters, and we want to count all distinct substrings that appear in s or in any version of s where exactly one character has been replaced by an asterisk.

codeforcescompetitive-programmingstring-suffix-structures
CF 1276B - Two Fairs

We are given a connected undirected graph of cities. Among all cities, two special nodes are distinguished, call them a and b, representing two fairs.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardsugraphs
CF 1277A - Happy Birthday, Polycarp!

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingimplementation
CF 1277D - Let's Play the Words?

We are given a collection of binary strings, and we are allowed to optionally reverse some of them. After doing so, we want to arrange all strings in a single sequence such that every adjacent pair is compatible: the last character of a word must match the first character of…

codeforcescompetitive-programmingdata-structureshashingimplementationmath
CF 1278C - Berry Jam

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingdata-structuresdpgreedyimplementation
CF 1278B - A and B

We are given two integers, and we are allowed to repeatedly perform operations where the cost of the k-th operation is exactly k. Each operation lets us choose one of the two numbers and add the current operation index to it.

codeforcescompetitive-programminggreedymath
CF 1279B - Verse For Santa

We are given a sequence of durations, where each value represents how long Vasya needs to recite one part of a verse. He must recite the parts in order, from left to right, and he earns a reward equal to how many parts he manages to fully complete before time runs out.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
CF 1280F - Intergalactic Sliding Puzzle

We are asked to rearrange a scrambled 2-row grid of alien organs into a prescribed order. The grid has dimensions 2 × (2k + 1) with 4k + 1 organs numbered 1 through 4k + 1 and exactly one empty cell.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsmath
CF 1280A - Cut and Paste

The process starts with a short string made only of digits 1, 2, and 3. Alongside this string, we maintain a cursor that moves from left to right over positions between characters, and a clipboard that can store a copied suffix of the string.

codeforcescompetitive-programmingimplementationmath
CF 1282A - Temporarily unavailable

We are given a person moving along a straight line segment from position a to position b at constant speed 1 unit per minute. Independently, there is a network base station at position c that covers everything within distance r.

codeforcescompetitive-programmingimplementationmath
CF 1283C - Friends and Gifts

We are given a directed assignment problem on $n$ people where each person must end up choosing exactly one other person to give a gift to, and at the same time must receive exactly one gift from someone else.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresmath
CF 1284C - New Year and Permutation

We need the total number of framed segments across all permutations of length n. For a fixed permutation, a segment [l, r] is framed when the values inside it form a set of consecutive integers.

codeforcescompetitive-programmingcombinatoricsmath
CF 1285A - Mezo Playing Zoma

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingmath
CF 1285B - Just Eat It!

We have an array representing the tastiness of cupcakes, and two players. Yasser always takes all the cupcakes, summing up the full array. Adel can pick any contiguous subarray that does not cover the entire array.

codeforcescompetitive-programmingdpgreedyimplementation
CF 1286E - Fedya the Potter Strikes Back

We are asked to maintain a string S and an integer array W dynamically as queries arrive. Each query adds a new character to S and a weight to W.

codeforcescompetitive-programmingdata-structuresstrings
CF 1286A - Garland

We are given a row of n bulbs, each numbered from 1 to n. Some bulbs are missing, indicated by zeros in the input array.

codeforcescompetitive-programmingdpgreedysortings
CF 1287B - Hyperset

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1288C - Two Arrays

We need to count pairs of arrays $(a,b)$, both of length $m$, whose values lie between $1$ and $n$. Array $a$ must be non-decreasing, array $b$ must be non-increasing, and at every position we require $ai le bi$. The answer can be very large, so we output it modulo $10^9+7$.

codeforcescompetitive-programmingcombinatoricsdp
CF 1288A - Deadline

For each test case, we have a deadline of n days and a program that normally needs d days to finish. Before running the program, we may spend x days optimizing it.

codeforcescompetitive-programmingbinary-searchbrute-forcemathternary-search
CF 1290C - Prefix Enlightenment

We have a line of n lamps, each either on or off. The goal is to compute, for every prefix of the lamps, the minimum number of subset toggle operations required to turn all lamps in that prefix on.

codeforcescompetitive-programmingdfs-and-similardsugraphs
CF 1292F - Nora's Toy Boxes

We are given a collection of n distinct toy boxes, each labeled with a positive integer ai. ROBO can perform a very specific action multiple times: pick three distinct boxes where one box's label divides the other two, and then remove the third box to place it on his pile.

codeforcescompetitive-programmingbitmaskscombinatoricsdp
CF 1292A - NEKO's Maze Game

We are given a 2-row by $n$-column grid representing a maze. The player starts at the top-left cell $(1,1)$ and wants to reach the bottom-right cell $(2,n)$. Movement is allowed only between orthogonally adjacent cells. Initially, all cells are passable ground.

codeforcescompetitive-programmingdata-structuresdsuimplementation
CF 1293A - ConneR and the A.R.C. Markland-N

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
CF 1294E - Obtain a Permutation

We are given an $n times m$ matrix. The target matrix is completely fixed: row-major order from $1$ to $n cdot m$. The value that should end up in position $(r,c)$ is $$(r-1)cdot m + c.$$ We may perform two kinds of operations.

codeforcescompetitive-programminggreedyimplementationmath
CF 1294C - Product of Three Numbers

For each test case, we are given a single integer n. We must determine whether n can be written as the product of three distinct integers a, b, and c, where each of them is at least 2. If such a decomposition exists, we print "YES" and one valid triple.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1294A - Collecting Coins

We are asked to decide whether a given number of coins can be distributed among three sisters so that they all end up with the same total number of coins. Each sister already has some coins: Alice has a, Barbara has b, and Cerene has c.

codeforcescompetitive-programmingmath
CF 1295F - Good Contest

We are given a contest with n problems, where each problem i has a range [li, ri] representing the possible number of accepted solutions. Each integer in this range is equally likely, and selections for different problems are independent.

codeforcescompetitive-programmingcombinatoricsdpprobabilities
CF 1295B - Infinite Prefixes

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingmathstrings
CF 1295C - Obtain The String

We are given two strings, s and t. Initially, we have an empty string z, and we want to transform z into t. The allowed operation is to append any subsequence of s to z. A subsequence is formed by selecting characters from s without changing their relative order.

codeforcescompetitive-programmingdpgreedystrings
CF 1296E1 - String Coloring (easy version)

We have a string of lowercase letters. Every position must be assigned one of two colors, 0 or 1. After choosing the colors, we are allowed to swap neighboring characters only when their colors are different. We may perform such swaps as many times as we want.

codeforcescompetitive-programmingconstructive-algorithmsdpgraphsgreedysortings
CF 1296C - Yet Another Walking Robot

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingdata-structuresimplementation
CF 1296A - Array with Odd Sum

We have an array of integers. An operation allows us to pick two different positions and copy the value from one position into the other. Since we may repeat this operation any number of times, values can be duplicated throughout the array.

codeforcescompetitive-programmingmath
CF 1297B - Cartoons

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programming*specialimplementationsortings
CF 1297A - Likes Display

The task is to convert a raw number of likes into a compact, human-readable format for display. Numbers less than a thousand remain as-is, numbers in the thousands are rounded to the nearest thousand with a 'K' suffix, and numbers in the millions are rounded to the nearest…

codeforcescompetitive-programming*specialimplementation
CF 1299B - Aerodynamic

We are given a strictly convex polygon $P$ in the plane as a list of its vertices in counterclockwise order. Each vertex has integer coordinates, and no three vertices are collinear.

codeforcescompetitive-programminggeometry
CF 1300A - Non-zero

We are given an array of integers and want to make two properties simultaneously true: the sum of the elements must not be zero, and the product of the elements must not be zero. The only operation allowed is incrementing a single element by one.

codeforcescompetitive-programmingimplementationmath
CF 1301F - Super Jaber

We are given a rectangular grid where every cell represents a city, and each city has one of a small number of colors.

codeforcescompetitive-programmingdfs-and-similargraphsimplementationshortest-paths
CF 1301C - Ayoub's function

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingbinary-searchcombinatoricsgreedymathstrings
CF 1302H - Who needs suffix structures?

We are given a sequence of length n. Although the statement talks about a string, the characters are represented by integers, and the alphabet is extremely large. The large alphabet size means we cannot rely on tricks that depend on a small number of distinct symbols.

codeforcescompetitive-programming
CF 1302B - DAG

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingconstructive-algorithms
CF 1302C - Segment tree or Fenwick?

We are asked to maintain an array of integers that starts with all zeros and answer a series of queries. Each query is either an assignment, setting a specific element to a value, or a range sum query, asking for the sum of a contiguous subarray.

codeforcescompetitive-programmingdata-structures
CF 1303A - Erasing Zeroes

We are given a binary string, a sequence of 0's and 1's, and the goal is to manipulate it so that all the 1's appear in one contiguous block. The only allowed operation is to remove some 0's.

codeforcescompetitive-programmingimplementationstrings
CF 1304E - 1-Trees and Queries

We are given a tree with $n$ vertices, where each vertex is connected such that there is exactly one path between any two vertices. Then we are asked multiple queries.

codeforcescompetitive-programmingdata-structuresdfs-and-similarshortest-pathstrees
CF 1304C - Air Conditioner

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingdpgreedyimplementationsortingstwo-pointers
CF 1305B - Kuroni and Simple Strings

The algorithm itself is correct. The bug is in the editorial's test harness code, not in the algorithm. In the posted solution, the pairs initialization was accidentally split across lines: That formatting artifact can cause issues when copied, and more importantly, the helper…

codeforcescompetitive-programmingconstructive-algorithmsgreedystringstwo-pointers
CF 1305A - Kuroni and the Gifts

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedysortings
CF 1307C - Cow and Message

We are given a string of lowercase English letters. A message is any subsequence whose chosen indices form an arithmetic progression. The progression can have any positive difference, including the special case of length one. The task is not to find the message itself.

codeforcescompetitive-programmingbrute-forcedpmathstrings
CF 1307E - Cow and Treats

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbinary-searchcombinatoricsdpgreedyimplementationmath
CF 1310A - Recommendations

Codeforces 1310A: Recommendations

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1310F - Bad Cryptography

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingmathnumber-theory
CF 1310C - Au Pont Rouge

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbinary-searchdpstrings
CF 1311C - Perform the Combo

We are given a fixed string s that represents a sequence of button presses in a fighting game combo. The player repeatedly attempts to type this entire string from left to right. However, the process is interrupted.

codeforcescompetitive-programmingbrute-force
CF 1311A - Add Odd or Subtract Even

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programminggreedyimplementationmath
CF 1312D - Count the Arrays

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingcombinatoricsmath
CF 1312G - Autocompletion

We are given a rooted construction of many strings where every node represents a string and every edge corresponds to appending one character. The root is the empty string, and each node i is created by taking its parent string pi and appending a lowercase letter ci.

codeforcescompetitive-programmingdata-structuresdfs-and-similardp
CF 1312C - Adding Powers

We are given an array of non-negative integers, and a base $k ge 2$. Starting from an array of zeroes of the same length, we can repeatedly pick a step $i$ and add $k^i$ to any single element of the array, or skip the step.

codeforcescompetitive-programmingbitmasksgreedyimplementationmathnumber-theoryternary-search
CF 1313D - Happy New Year

We are given a large line of positions from 1 to $m$, and a collection of $n$ intervals. Each interval represents a “spell” that, when used, adds one candy to every position inside its range. Each spell can be used at most once.

codeforcescompetitive-programmingbitmasksdpimplementation
CF 1313C1 - Skyscrapers (easy version)

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedy
CF 1313B - Different Rules

Each participant in the contest has two independent rankings: one from the first round and one from the second round. No ties exist in either round, so each round is a permutation of ranks from 1 to n. A participant’s final value is the sum of their two ranks.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1316B - String Modification

We are given a string of length $n$, and Vasya wants to perform a sequence of substring reversals to produce the lexicographically smallest string possible. The operation is controlled by an integer $k$, which specifies the length of each consecutive substring to reverse.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationsortingsstrings
CF 1316C - Primitive Primes

We are given two polynomials, each represented by an array of positive integers, which are their coefficients. The first polynomial has $n$ terms and coefficients $a0, a1, dots, a{n-1}$, the second has $m$ terms with coefficients $b0, b1, dots, b{m-1}$.

codeforcescompetitive-programmingconstructive-algorithmsmathternary-search
CF 1320C - World of Darkraft: Battle for Azathoth

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forcedata-structuressortings
CF 1322C - Instant Noodles

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programminggraphshashingmathnumber-theory
CF 1325C - Ehab and Path-etic MEXs

We are given a tree with $n$ nodes, represented by $n-1$ edges connecting pairs of nodes. Each edge must be assigned a distinct integer label between $0$ and $n-2$.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargreedytrees
CF 1326F2 - Wise Men (Hard Version)

We are asked to analyze permutations of a group of $n$ wise men, where some pairs of them know each other. For each permutation of these wise men, we can create a binary string of length $n-1$ indicating adjacency of acquaintances: a '1' if two consecutive wise men in the…

codeforcescompetitive-programmingbitmasksdpmath
CF 1326A - Bad Ugly Numbers

We need to construct a positive decimal number with exactly n digits. Every digit must be nonzero, and the whole number must fail divisibility by each digit that appears in it. For each test case, the input gives only the required length n.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1326D1 - Prefix-Suffix Palindrome (Easy version)

We are given a string consisting of lowercase English letters, and the task is to construct the longest palindrome by combining a prefix and a suffix of this string.

codeforcescompetitive-programminghashingstring-suffix-structuresstrings
CF 1327A - Sum of Odd Integers

The problem asks whether a given integer n can be expressed as the sum of exactly k distinct positive odd integers. Each test case provides n and k, and the answer is either "YES" or "NO". Odd integers are numbers not divisible by 2, so valid candidates are 1, 3, 5, 7,....

codeforcescompetitive-programmingmath
CF 1328A - Divisibility Problem

Each test case contains two positive integers. We may only perform one kind of operation: increase the first number by one.

codeforcescompetitive-programmingmath
CF 1328E - Tree Queries

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programmingdfs-and-similargraphstrees
CF 1330B - Dreamoon Likes Permutations

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programmingimplementationmath
CF 1331H - It's showtime

The problem presents a single integer input that encodes two pieces of information. The integer can be decomposed as input = 1000 n + mod, where n is the number for which we want the double factorial and mod is the modulus to compute it under.

codeforcescompetitive-programming*special
CF 1331B - Limericks

The problem asks us to compute a specific numeric property related to an integer input, denoted as a. While the problem statement is written in a poetic form, the underlying task is to find the number of integers less than a that are coprime to a.

codeforcescompetitive-programming*specialmathnumber-theory
CF 1331A - Is it rated?

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programming*special
CF 1332F - Independent Set

We are given a tree with $n$ vertices. For every nonempty subset of edges $E'$, we build the edge-induced subgraph consisting of those edges and every endpoint that appears in at least one selected edge. For that subgraph we count its independent sets.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 1332C - K-Complete Word

We are given a string s of length n and an integer k such that n is divisible by k. A string is considered k-complete if it is both a palindrome and periodic with period k. Being a palindrome means the string reads the same forwards and backwards.

codeforcescompetitive-programmingdfs-and-similardsugreedyimplementationstrings
CF 1332B - Composite Coloring

The reviewer is correct. The displayed sequences are not addition chains, because the quantities $2^g,2^h,2^k,2^m$ were used as summands without first appearing as chain elements. The argument must be rebuilt from the definition of a star chain.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymathnumber-theory
CF 1333D - Challenges in school №41

The reviewer is correct. The displayed sequences are not addition chains, because the quantities $2^g,2^h,2^k,2^m$ were used as summands without first appearing as chain elements. The argument must be rebuilt from the definition of a star chain.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgamesgraphsgreedyimplementationsortings
CF 1334G - Substring Search

We are asked to find all substrings of a string t that "match" another string s according to a flexible definition of equality.

codeforcescompetitive-programmingbitmasksbrute-forcefft
CF 1334E - Divisor Paths

We are given a number $D$ and need to reason about all of its divisors. The problem defines a graph whose vertices are all divisors of $D$. An edge exists from a divisor $y$ to a larger divisor $x$ if $x$ is divisible by $y$ and the quotient $x / y$ is prime.

codeforcescompetitive-programmingcombinatoricsgraphsgreedymathnumber-theory