## Divisible Numbers

Given an integer, n, find the smallest integer m such that m is divisible by n (i.e., n is a factor of m) and satisfies the following properties:n m must not contain zeroes in its decimal representation. The sum of m's digits must be greater than or equal to the product of m's digits. Given n, find m and print the number of digits in m's decimal representation. Input Format A single integer denoting n. Constraints 1 <= n <= 3*10^4 n is not divisible by 10. Time Limits The tim

View Solution →## Unique Divide And Conquer

Divide-and-Conquer on a tree is a powerful approach to solving tree problems. Imagine a tree, t, with n vertices. Let's remove some vertex v from tree t, splitting t into zero or more connected components, t1,t2,...,tk, with vertices n1,n2,...,nk. We can prove that there is a vertex, , such that the size of each formed components is at most [n/2]. The Divide-and-Conquer approach can be described as follows: Initially, there is a tree, t, with n vertices. Find vertex v such that, if v i

View Solution →## King and Four Sons

The King of Byteland wants to grow his territory by conquering K other countries. To prepare his 4 heirs for the future, he decides they must work together to capture each country. The King has an army, A, of N battalions; the ith battalion has Ai soldiers. For each battle, the heirs get a detachment of soldiers to share but will fight amongst themselves and lose the battle if they don't each command the same number of soldiers (i.e.: the detachment must be divisible by 4). If given a detachm

View Solution →## Dortmund Dilemma

Borussia Dortmund are a famous football ( soccer ) club from Germany. Apart from their fast-paced style of playing, the thing that makes them unique is the hard to pronounce names of their players ( błaszczykowski , papastathopoulos , großkreutz etc. ). The team's coach is your friend. He is in a dilemma as he can't decide how to make it easier to call the players by name, during practice sessions. So, you advise him to assign easy names to his players. A name is easy to him if 1. It consi

View Solution →## Super Kth LIS

Given an array of N integers (a0,a1,...,aN-1), find all possible increasing subsequences of maximum length, L. Then print the lexicographically Kth longest increasing subsequence as a single line of space-separated integers; if there are less than K subsequences of length L, print -1. Two subsequences [ap0,ap1,...,apL-1] and [aq0,aq1,...,aqL-1] are considered to be different if there exists at least one i such that pi != qi. Input Format The first line contains 2 space-separated integer

View Solution →