brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 81D - Polycarp's Picture Gallery

We have several photo albums. Album i contains a[i] photos. We must build a cyclic gallery containing exactly n photos. Instead of choosing concrete photo IDs, we only need to output the album number for each position. The gallery is circular, so every position has two neighbors.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
LeetCode 492 - Construct the Rectangle

The problem gives us a single integer, area, which represents the area of a rectangle. Our task is to find two integers: - L, the length - W, the width such that: 1. L W == area 2. L = W 3.

leetcodeeasymath
LeetCode 15 - 3Sum

The problem gives us an integer array nums, and we need to find every unique triplet of numbers whose sum is exactly 0. A triplet consists of three different indices: - i != j - i != k - j != k The values themselves may be equal, but the indices must be different.

leetcodemediumarraytwo-pointerssorting
LeetCode 1140 - Stone Game II

The problem is a two-player turn-based game played on a row of stone piles. Each pile has a positive number of stones, and players take turns taking stones from the start of the remaining piles.

leetcodemediumarraymathdynamic-programmingprefix-sumgame-theory
LeetCode 642 - Design Search Autocomplete System

The problem asks us to design an autocomplete system that behaves similarly to a search engine suggestion feature. The system starts with a collection of historical sentences and the number of times each sentence has been typed before.

leetcodehardstringdepth-first-searchdesigntriesortingheap-(priority-queue)data-stream
LeetCode 28 - Find the Index of the First Occurrence in a String

This problem asks us to locate the first occurrence of one string inside another string. The string we are searching for is called needle, and the larger string we search inside is called haystack.

leetcodeeasytwo-pointersstringstring-matching
CF 120F - Spiders

We are given a collection of toy spiders. Each spider is a tree, represented by beads (nodes) connected with strings (edges). A spider with $k$ beads has $k-1$ strings connecting its beads so that all beads are connected and there are no cycles.

codeforcescompetitive-programmingdpgreedytrees
LeetCode 746 - Min Cost Climbing Stairs

This problem gives us an array named cost, where each element represents the cost of stepping onto a particular stair. If cost[i] equals 10, that means stepping on stair i requires paying 10. From any stair, we are allowed to move either one step or two steps upward.

leetcodeeasyarraydynamic-programming
LeetCode 1686 - Stone Game VI

This is a long, structured technical guide with multiple substantial sections, worked examples, code, tables, and test c

leetcodemediumarraymathgreedysortingheap-(priority-queue)game-theory
LeetCode 1373 - Maximum Sum BST in Binary Tree

This problem asks us to examine every possible subtree inside a binary tree and determine whether that subtree forms a valid Binary Search Tree, abbreviated as BST. Among all valid BST subtrees, we must return the maximum possible sum of node values.

leetcodeharddynamic-programmingtreedepth-first-searchbinary-search-treebinary-tree
CF 60C - Mushroom Strife

We have an undirected graph where each vertex stores some positive integer, the number of mushrooms on that lawn. For every known edge, we are given two values: the gcd of the two endpoint values and the lcm of the two endpoint values.

codeforcescompetitive-programmingbrute-forcedfs-and-similar
LeetCode 544 - Output Contest Matches

The problem asks us to simulate the structure of a playoff tournament bracket. We are given n teams, numbered from 1 to n, where smaller numbers represent stronger teams.

leetcodemediumstringrecursionsimulation
CF 106E - Space Rescuers

We are asked to place a space rescue station in three-dimensional space such that the maximum distance from it to any of the given planets is minimized. Each planet is represented by its coordinates $(x, y, z)$.

codeforcescompetitive-programminggeometryternary-search
LeetCode 1612 - Check If Two Expression Trees are Equivalent

The problem asks us to determine whether two binary expression trees are equivalent, where equivalence is defined as the trees representing the same arithmetic expression, modulo the order of addition since addition is commutative.

leetcodemediumhash-tabletreedepth-first-searchbinary-treecounting
CF 21A - Jabber ID

We need to validate whether a string follows the exact syntax of a Jabber ID.

codeforcescompetitive-programmingimplementationstrings
LeetCode 341 - Flatten Nested List Iterator

This problem asks us to design an iterator that can traverse a deeply nested list structure as if it were a flat list of integers. The input is not a normal array.

leetcodemediumstacktreedepth-first-searchdesignqueueiterator
CF 17A - Noldbach problem

We are given two integers, n and k. We look at all prime numbers from 2 up to n. Among those primes, we want to count how many can be written in the form:

codeforcescompetitive-programmingbrute-forcemathnumber-theory
LeetCode 1711 - Count Good Meals

The problem asks us to count the number of good meals that can be formed from a given list of food items. A good meal is defined as a pair of two different items whose combined deliciousness is a power of two.

leetcodemediumarrayhash-table
LeetCode 665 - Non-decreasing Array

The problem asks whether it is possible to transform a given integer array into a non-decreasing array by modifying at most one element. A non-decreasing array means that every element is less than or equal to the element that comes after it.

leetcodemediumarray
LeetCode 324 - Wiggle Sort II

The problem asks us to rearrange an array so that it follows a strict alternating pattern: - nums[0] < nums[1] - nums[1] nums[2] - nums[2] < nums[3] - and so on. This pattern is called a wiggle sequence because the values repeatedly go up and down.

leetcodemediumarraydivide-and-conquergreedysortingquickselect
LeetCode 298 - Binary Tree Longest Consecutive Sequence

The problem asks us to find the length of the longest consecutive sequence path in a binary tree, where a consecutive sequence path is defined as a path in which the values increase by exactly one from parent to child.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 1318 - Minimum Flips to Make a OR b Equal to c

The problem gives us three positive integers, a, b, and c. We are allowed to flip individual bits in either a or b. A flip means changing a bit from 0 to 1 or from 1 to 0. Our goal is to perform the minimum number of bit flips so that: The OR operation works bit by bit.

leetcodemediumbit-manipulation
CF 60A - Where Are My Flakes?

There are n boxes arranged in a straight line. Exactly one of them may contain the cereal flakes. The roommate leaves statements of two possible forms. If the hint says "To the left of i", then the flakes must be somewhere strictly before box i. Box i itself is also impossible.

codeforcescompetitive-programmingimplementationtwo-pointers
LeetCode 1066 - Campus Bikes II

That is a long-form technical guide with multiple required sections and detailed worked examples. I can provide the complete reference document, but it will be quite lengthy.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 1674 - Minimum Moves to Make Array Complementary

The problem requires us to transform an array nums of even length n into a complementary array. An array is complementar

leetcodemediumarrayhash-tableprefix-sum
LeetCode 1643 - Kth Smallest Instructions

This problem asks us to generate a specific path for Bob from the top-left corner (0, 0) to a destination (row, column)

leetcodehardarraymathdynamic-programmingcombinatorics
LeetCode 1705 - Maximum Number of Eaten Apples

The problem describes a scenario with a series of apple trees that grow apples for n consecutive days. Each day, the tree produces a number of apples given by apples[i], and these apples have a limited lifespan, given by days[i].

leetcodemediumarraygreedyheap-(priority-queue)
LeetCode 927 - Three Equal Parts

The problem asks us to partition a binary array arr into three non-empty contiguous segments such that each segment, when interpreted as a binary number (allowing leading zeros), is equal to the other two segments.

leetcodehardarraymath
LeetCode 1108 - Defanging an IP Address

The problem asks us to transform a valid IPv4 address into its "defanged" version. A defanged IP address is created by replacing every period character "." with the string "[.]". An IPv4 address consists of four numeric segments separated by periods. For example, "1.1.1.

leetcodeeasystring
LeetCode 409 - Longest Palindrome

The problem asks us to find the length of the longest palindrome that can be constructed using the characters of a given string s. A palindrome is a string that reads the same forwards and backwards.

leetcodeeasyhash-tablestringgreedy
LeetCode 721 - Accounts Merge

This problem asks us to merge user accounts based on shared email addresses. Each account is represented as a list of strings. The first string is the user's name, and every remaining string is an email address associated with that account.

leetcodemediumarrayhash-tablestringdepth-first-searchbreadth-first-searchunion-findsorting
LeetCode 101 - Symmetric Tree

The problem asks us to determine whether a binary tree is symmetric around its center. A tree is symmetric if the left subtree is a mirror reflection of the right subtree.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
CF 46D - Parking Lot

We have a parking segment represented by the interval [0, L]. Cars arrive one at a time, always driving from left to right, and each driver wants to park at the earliest possible position.

codeforcescompetitive-programmingdata-structuresimplementation
LeetCode 790 - Domino and Tromino Tiling

The problem asks us to compute the number of ways to completely tile a 2 x n board using two types of tiles: a domino (2 x 1) and a tromino shape.

leetcodemediumdynamic-programming
LeetCode 1099 - Two Sum Less Than K

This problem asks us to find the maximum sum of any two distinct numbers in an integer array nums such that their sum is strictly less than a given integer k.

leetcodeeasyarraytwo-pointersbinary-searchsorting
LeetCode 49 - Group Anagrams

The problem asks us to group together all strings that are anagrams of each other. Two strings are considered anagrams if they contain exactly the same characters with the same frequencies, but possibly in a different order.

leetcodemediumarrayhash-tablestringsorting
LeetCode 162 - Find Peak Element

The problem gives us an integer array nums and asks us to find the index of any peak element. A peak element is defined as an element that is strictly greater than its immediate neighbors.

leetcodemediumarraybinary-search
LeetCode 1405 - Longest Happy String

The problem asks us to construct the longest possible string using only the characters 'a', 'b', and 'c', while satisfyi

leetcodemediumstringgreedyheap-(priority-queue)
LeetCode 848 - Shifting Letters

This problem asks us to repeatedly apply character shifts to a string of lowercase English letters. We are given two inputs: - A string s, consisting only of lowercase English letters.

leetcodemediumarraystringprefix-sum
LeetCode 1490 - Clone N-ary Tree

This problem asks us to create a deep copy of an N-ary tree. An N-ary tree is a tree where each node can have zero or mo

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-search
LeetCode 436 - Find Right Interval

This problem asks us to find, for each interval in a list, the "right interval" that starts at or after the end of the current interval and is the closest such interval in terms of starting time.

leetcodemediumarraybinary-searchsorting
LeetCode 1205 - Monthly Transactions II

This problem asks us to generate a monthly financial summary for each country using information from two database tables: Transactions and Chargebacks. The Transactions table stores incoming transactions.

leetcodemediumdatabase
CF 130C - Decimal sum

We are given a sequence of integers and need to compute their total sum. The input starts with an integer n, which tells us how many numbers follow. Each of the next n lines contains one element of the array. The task is simply to add all of them together and print the result.

codeforcescompetitive-programming*special
CF 49C - Disposition

We need to build a permutation of numbers from 1 to n. Position j contains volume p(j). A positive integer i is called a divisor of the disposition if there exists some position j such that both j and p(j) are divisible by i.

codeforcescompetitive-programmingconstructive-algorithmsmath
LeetCode 836 - Rectangle Overlap

The problem gives us two axis-aligned rectangles, meaning their sides are parallel to the X-axis and Y-axis. Each rectangle is represented as: Where: - (x1, y1) is the bottom-left corner - (x2, y2) is the top-right corner The task is to determine whether these two rectangles…

leetcodeeasymathgeometry
CF 64A - Factorial

We are asked to compute the factorial of a given integer $n$. Factorial is the product of all positive integers up to $n$, so for $n = 3$, the factorial is $1 times 2 times 3 = 6$. The input is a single integer, and the output is the single integer result of this product.

codeforcescompetitive-programming*specialimplementation
CF 22A - Second Order Statistics

We are given a small array of integers and need to find the smallest value that is strictly larger than the minimum element in the array.

codeforcescompetitive-programmingbrute-force
CF 66A - Petya and Java

We are given a decimal integer as a string. The number can be extremely large, up to 100 digits long, so it may not fit into normal integer types in many programming languages. The task is to determine the smallest Java integer type that can store this value.

codeforcescompetitive-programmingimplementationstrings
LeetCode 19 - Remove Nth Node From End of List

This problem asks us to remove the nth node counted from the end of a singly linked list and return the modified list. A singly linked list is a sequence of nodes where each node contains a value and a pointer to the next node.

leetcodemediumlinked-listtwo-pointers
LeetCode 1670 - Design Front Middle Back Queue

The problem is asking us to design a specialized queue that allows insertions and removals not only at the front and bac

leetcodemediumarraylinked-listdesignqueuedoubly-linked-listdata-stream
LeetCode 267 - Palindrome Permutation II

The problem asks us to generate every unique palindrome that can be formed by rearranging the characters of a given string. A palindrome is a string that reads the same forward and backward. For example, "abba" and "racecar" are palindromes.

leetcodemediumhash-tablestringbacktracking
LeetCode 1092 - Shortest Common Supersequence

The problem asks us to construct the shortest possible string that contains both str1 and str2 as subsequences. A subsequence does not require characters to appear contiguously. Instead, the characters only need to appear in the same relative order.

leetcodehardstringdynamic-programming
CF 89D - Space mines

The Death Star is a sphere of radius R. Its center starts at point A and moves forever in a straight line with constant velocity vector v. Every mine consists of two kinds of geometry. The first part is a sphere centered at O with radius r. The second part is a set of spikes.

codeforcescompetitive-programminggeometry
LeetCode 1416 - Restore The Array

The problem gives us a string s that represents several positive integers concatenated together without spaces. Original

leetcodehardstringdynamic-programming
LeetCode 1319 - Number of Operations to Make Network Connected

This problem models a computer network as an undirected graph. Each computer is a node, and each ethernet cable is an ed

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 752 - Open the Lock

The problem presents a lock with four wheels, each wheel labeled from '0' to '9', which can rotate forwards or backwards. The lock starts at '0000', and we are given a list of "deadends," which are lock states that will cause the lock to freeze if reached.

leetcodemediumarrayhash-tablestringbreadth-first-search
LeetCode 1377 - Frog Position After T Seconds

This problem describes a frog moving through an undirected tree. A tree is a connected graph with no cycles, which means

leetcodehardtreedepth-first-searchbreadth-first-searchgraph-theory
LeetCode 401 - Binary Watch

The problem describes a binary watch that uses LEDs to represent time. The watch has two sections. The top section contains 4 LEDs for the hour, and the bottom section contains 6 LEDs for the minutes. Each LED represents a binary digit.

leetcodeeasybacktrackingbit-manipulation
LeetCode 592 - Fraction Addition and Subtraction

The problem requires computing the result of a mathematical expression containing fractions with addition and subtraction operators. The input is a single string, expression, which consists of positive or negative fractions in the format numerator/denominator.

leetcodemediummathstringsimulation
LeetCode 125 - Valid Palindrome

This problem asks us to determine whether a given string is a palindrome after applying two transformations: 1. Convert all uppercase letters to lowercase. 2. Remove all non-alphanumeric characters. An alphanumeric character is any English letter (a-z, A-Z) or digit (0-9).

leetcodeeasytwo-pointersstring
LeetCode 1241 - Number of Comments per Post

This problem asks us to analyze a database table named Submissions and determine how many unique comments belong to each post.

leetcodeeasydatabase
LeetCode 352 - Data Stream as Disjoint Intervals

This problem asks us to process a stream of non-negative integers and continuously maintain a compact representation of all numbers seen so far. Instead of storing every individual number separately, we want to group consecutive numbers into disjoint intervals.

leetcodehardhash-tablebinary-searchunion-finddesigndata-streamordered-set
CF 131D - Subway

We are given a subway system of n stations connected by exactly n passages, each passage connecting two distinct stations. The system forms a connected graph where each station can reach every other station.

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 1739 - Building Boxes

The problem gives us n identical unit cubes that must be placed inside a cubic room. The goal is to minimize how many boxes directly touch the floor. The placement rule is the important part of the problem.

leetcodehardmathbinary-searchgreedy
LeetCode 1605 - Find Valid Matrix Given Row and Column Sums

The problem gives us two arrays: - rowSum, where rowSum[i] represents the total sum required for row i - colSum, where c

leetcodemediumarraygreedymatrix
LeetCode 1528 - Shuffle String

The problem asks us to take a string s and an integer array indices of the same length, and produce a new string where e

leetcodeeasyarraystring
CF 103A - Testing Pants for Sadness

The test contains several questions that must be answered in order. Each question has multiple answer choices, and exactly one of them is correct. Vaganych does not know any correct answers in advance, but after making a mistake he remembers which options were wrong.

codeforcescompetitive-programminggreedyimplementationmath
CF 14D - Two Paths

We are given a tree of n cities, meaning each city is connected in such a way that there is exactly one simple path between any two cities. Roads are undirected, and each road has a length of 1.

codeforcescompetitive-programmingdfs-and-similardpgraphsshortest-pathstreestwo-pointers
LeetCode 92 - Reverse Linked List II

This problem asks us to reverse only a specific portion of a singly linked list, rather than reversing the entire list. We are given the head of a linked list and two integer positions, left and right, where left <= right.

leetcodemediumlinked-list
CF 9D - How many trees?

We are asked to count the number of distinct binary search trees (BSTs) that have exactly n nodes labeled from 1 to n, with the additional constraint that the height of each tree is at least h.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerdp
CF 103C - Russian Roulette

The cylinder has n slots arranged in a circle, and exactly k of them contain bullets. Before the game starts, the cylinder is rotated uniformly at random, so every cyclic shift is equally likely. After the rotation, Sasha shoots first.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
LeetCode 1409 - Queries on a Permutation With Key

This problem asks us to simulate a dynamic permutation of integers and answer position queries as elements continuously

leetcodemediumarraybinary-indexed-treesimulation
LeetCode 1123 - Lowest Common Ancestor of Deepest Leaves

This problem asks us to find the lowest common ancestor, abbreviated as LCA, of all the deepest leaf nodes in a binary tree. A leaf node is any node with no children. The depth of the root is 0, and every level downward increases the depth by 1.

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 216 - Combination Sum III

This problem asks us to generate all unique combinations of exactly k distinct numbers chosen from the range 1 to 9 such that their sum equals n. Each number can only be used once in a combination. This means combinations like [1,1,5] are invalid because the number 1 is repeated.

leetcodemediumarraybacktracking
LeetCode 1037 - Valid Boomerang

This problem asks us to determine whether three given points in a 2D Cartesian plane form a valid boomerang. A boomerang is defined as a set of three points that are all distinct and not in a straight line. In other words, the points must not coincide and must not be collinear.

leetcodeeasyarraymathgeometry
CF 43A - Football

We are given the sequence of goals scored during a football match. Every line after the first contains the name of the team that scored one goal. The task is to determine which team scored more goals overall.

codeforcescompetitive-programmingstrings
LeetCode 1636 - Sort Array by Increasing Frequency

The problem asks us to reorder an array of integers based on the frequency of each value. Specifically, elements with lo

leetcodeeasyarrayhash-tablesorting
LeetCode 2005 - Subtree Removal Game with Fibonacci Tree

The problem defines a special kind of binary tree called a Fibonacci tree. The structure is recursive: - order(0) is an empty tree. - order(1) is a single node. - order(n) has: - a root node, - a left subtree equal to order(n - 2), - a right subtree equal to order(n - 1).

leetcodehardmathdynamic-programmingtreebinary-treegame-theory
CF 65C - Harry Potter and the Golden Snitch

The snitch moves along a fixed polyline in 3D space. It starts at the first vertex and travels segment by segment at constant speed vs. Harry starts at another point and can move in any direction at constant speed vp, where vp = vs.

codeforcescompetitive-programmingbinary-searchgeometry
LeetCode 426 - Convert Binary Search Tree to Sorted Doubly Linked List

The problem asks us to transform a Binary Search Tree, abbreviated as BST, into a sorted circular doubly linked list. The transformation must happen in place, meaning we are not allowed to create entirely new nodes for the linked list.

leetcodemediumlinked-liststacktreedepth-first-searchbinary-search-treebinary-treedoubly-linked-list
LeetCode 510 - Inorder Successor in BST II

This problem asks us to find the in-order successor of a given node inside a Binary Search Tree, abbreviated as BST. Unlike the classic version of the problem, we are not given access to the root of the tree.

leetcodemediumtreebinary-search-treebinary-tree
LeetCode 894 - All Possible Full Binary Trees

The problem asks us to generate every possible full binary tree that contains exactly n nodes. A full binary tree is a special kind of binary tree where every node has either exactly two children or no children at all. In other words, a node can never have only one child.

leetcodemediumdynamic-programmingtreerecursionmemoizationbinary-tree
LeetCode 1144 - Decrease Elements To Make Array Zigzag

The problem gives an integer array nums and allows only one type of operation, decreasing any element by 1. We may perform this operation as many times as needed on any elements. Our goal is to transform the array into a zigzag array with the minimum number of moves.

leetcodemediumarraygreedy
LeetCode 1743 - Restore the Array From Adjacent Pairs

The problem gives us all adjacent pairs from an unknown array nums, and our task is to reconstruct the original array. Suppose the original array was: The adjacent pairs would be: The important detail is that the pairs can appear in any order and can also be reversed.

leetcodemediumarrayhash-tabledepth-first-search
LeetCode 1817 - Finding the Users Active Minutes

This problem asks us to analyze a collection of user activity logs and determine how many users have a specific number of unique active minutes.

leetcodemediumarrayhash-table
CF 53B - Blog Photo

We are given the dimensions of an uploaded photo, height h and width w. We want to cut out a smaller rectangle from it. The cut rectangle must satisfy three conditions.

codeforcescompetitive-programmingbinary-searchimplementation
CF 33A - What is for dinner?

Each tooth belongs to exactly one row. When Valerie eats one crucian using a row, every tooth in that row loses one unit of viability. A row becomes unusable as soon as at least one tooth inside it would drop below zero.

codeforcescompetitive-programminggreedyimplementation
LeetCode 1265 - Print Immutable Linked List in Reverse

This problem gives us a special type of linked list called an immutable linked list. Unlike a normal linked list problem

leetcodemediumlinked-listtwo-pointersstackrecursion
LeetCode 1396 - Design Underground System

This problem asks us to design a small tracking system for an underground railway network. The system must support three

leetcodemediumhash-tablestringdesign
LeetCode 625 - Minimum Factorization

The problem asks us to find the smallest positive integer x such that the product of all of its digits equals the given integer num.

leetcodemediummathgreedy
CF 40E - Number Table

We are given a table representing the economy of Berland over n days and m months. Each cell in the table contains either 1 or -1, indicating a profit or a loss for that day of that month.

codeforcescompetitive-programmingcombinatorics
LeetCode 853 - Car Fleet

The problem describes a set of cars driving toward the same destination, represented by the integer target. Each car starts at a unique position and moves at a constant speed. Cars cannot overtake each other.

leetcodemediumarraystacksortingmonotonic-stack
LeetCode 457 - Circular Array Loop

This problem asks us to determine whether a circular array contains a valid cycle under a specific movement rule. Each element in the array represents how far we move from the current index.

leetcodemediumarrayhash-tabletwo-pointers
CF 50A - Domino piling

We are asked to place as many standard dominoes as possible on a rectangular board of size _M_ by _N_. Each domino covers exactly two adjacent squares, and dominoes cannot overlap or extend outside the board.

codeforcescompetitive-programminggreedymath
CF 54C - First Digit Law

We are given a set of N random integers, where each integer i can take any value in a given inclusive range [L_i, R_i], all values equally likely. The task is to compute the probability that at least K% of these N integers start with the digit 1.

codeforcescompetitive-programmingdpmathprobabilities
CF 7A - Kalevitch and Chess

The problem asks us to simulate a painter working on an 8×8 chessboard. Every square starts white, and the painter can perform only two operations: paint an entire row black or paint an entire column black. Painting the same square multiple times has no effect beyond the first.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
LeetCode 3054 - Binary Tree Nodes

This problem asks us to classify nodes in a binary tree based on their role in the tree structure. The input is represen

leetcodemediumdatabase
LeetCode 800 - Similar RGB Color

The problem is asking us to find the shorthand RGB color that is most similar to a given full-length RGB color string.

leetcodeeasymathstringenumeration
CF 130I - Array sorting

We are given an array of at most 100 integers. Every value lies between 1 and 60. The task is simply to print the array in non-decreasing order.

codeforcescompetitive-programming*specialsortings
CF 13A - Numbers

We are asked to compute the average sum of digits of a number _A_ when it is expressed in all bases from 2 up to _A_ - 1. The input is a single integer _A_ between 3 and 1000.

codeforcescompetitive-programmingimplementationmath