Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

If the only condition is that $a_i >= 3a_{i-1}$ for even i then this should be quite trivial? What subset sums can you achieve by just picking the last two array elements?


5

$n^2 + (n + 1)^2 = (n + 2)^2 \Rightarrow n^2 + n^2 + 2n + 1 = n^2 + 4n + 4 \Rightarrow 2n^2 2n + 1 = n^2 + 4n + 4 \Rightarrow n^2 - 2n - 3 = 0 \Rightarrow n = -1, 3$ Therefore, 3 is the only plausible solution.


0

Let's start with a simple algorithm. Go over all possible interpretations of the first string (using all possible bases). For each such interpretation, go over the remaining string, and check whether they equal the interpretation of the first string for one of the possible bases. If there are $m$ possible bases and $n$ digits in total, then the running time ...


2

Depending on the input values the following strategy might work: keep an array $C$ of $10^6$ elements where $C[i]$ will store the number of times number $i$ appears in the elements of the input array that have already been processed. Initially $C$ is identically 0, then you consider the elements $A_i$ one at a time. When you are processing the $A_i$ you can ...


Top 50 recent answers are included