1

Topic: a from company ABBYY

2

Re: a from company ABBYY

Hello, Kodt, you wrote: Easily! Than we will sacrifice - a warranty of a stop or autocorrelation?? Whether In my opinion here generally all tasks on "the person on interviews", especially last is able to panic. 1. 5-> 0. 4-> base 5-> base 25-> it is discarded all> 7. For esthetes - all> 21 also we give a remainder of division on 7.

3

Re: a from company ABBYY

Hello, Kodt, you wrote: And the present esthetes do not throw out> 21, and use.> m = 1 # random number upper bound r = 0 # number As a matter of fact, this arithmetical coding... I do not know as there at "esthetes" it is accepted to do, but in arithmetical coding also entropy between calls do not lose. Too it is prodigal to initialize start each time in pair {1, 0}. We tell, it is obvious that if it is necessary to simulate a fair coin having the generator rand8, to launch last it is possible only once on three answers://s = 5, d = 7 template <ui s, ui d> ui gen () {static ui g = 1, v = 0; do {while (g <d) {g * = s; v = v * s + random (s);}; ui f = g / d * d; if (v <f) {ui r = v % d; g / = d; v / = d; return r;} g - = f; v - = f;} while (1);}

4

Re: a from company ABBYY

Hello, Lepsik, you wrote: L> 3 1 L> the array from whole c Is given. To find such m <= k, that the total a [m] + a [m + 1] +... + a [k] it was maximum. The operating time should be the order of length of an array. And on an input that is given?

5

Re: a from company ABBYY

Hello, Kodt, you wrote: That is, sacrificed a stop. We after all can to   wait, while ceases to fall out> 21 of 25. Though the probability of this bad luck is small.> And the present esthetes do not throw out> 21, and use. And, so questions not application-oriented, and on spherical model of a horse in vacuum (in good sense)? Then the pass, brains are hopelessly spoiled by practice

6

Re: a from company ABBYY

Hello, - n1l - you wrote: L>> 3 1 L>> the array from whole c Is given. To find such m <= k, that the total a [m] + a [m + 1] +... + a [k] it was maximum. The operating time should be the order of length of an array. N> and on an input that is given? On an input an array of integer numbers, on an output m and k.

7

Re: a from company ABBYY

8

Re: a from company ABBYY

Hello, vsb, you wrote: that the total a [m] + a [m + 1] +... + a [k] it was maximum So it turns out to me it is possible to take  an array, whether that?

9

Re: a from company ABBYY

Hello, Kodt, you wrote: Easily! Than we will sacrifice - a warranty of a stop or autocorrelation? Than is bad to throw a naive variant of 7 times on 5, and to take away 5 times on 7?

10

Re: a from company ABBYY

Hello, - n1l - you wrote: N> So it turns out to me it is possible to take  an array, whether that? In the job it is told about integer numbers, and about not the natural. In terms / ++ it signed int numbers, instead of unsigned int

11

Re: a from company ABBYY

Hello, - n1l - you wrote: N> that the total a [m] + a [m + 1] +... + a [k] it was maximum N> So it turns out to me it is possible to take  an array, whether that? It is possible, but numbers can be negative, therefore it not mandatory right answer.

12

Re: a from company ABBYY

Hello, vsb, you wrote: Clearly, thanks.

13

Re: a from company ABBYY

Hello, bazis1, you wrote:> it is easy! Than we will sacrifice - a warranty of a stop or autocorrelation? B> than is bad to throw a naive variant of 7 times on 5, and to take away 5 times on 7? I understood nothing, it is possible more in detail? What means to take away 5 times on 7? Better the specific code or on an example. Fell out 1 2 3 4 5 4 3, further that will do?

14

Re: a from company ABBYY

They should go is mandatory successively?

15

Re: a from company ABBYY

Hello, - n1l - you wrote: N> They should go is mandatory successively? Yes, differently what would be sense in this task.

16

Re: a from company ABBYY

Hello, - n1l - you wrote: N> So it turns out to me it is possible to take  an array, whether that? If all numbers nonnegative it is possible. Generally it suspiciously starts to remind scheduling, which NP-full. Was specific here to check laziness, but, , this hobby  - to palm off the disguised NP-full task and with innocent eyes to ask to find the optimal decision for polynominal time.

17

Re: a from company ABBYY

Hello, bazis1, you wrote: B> if all numbers nonnegative it is possible. Generally it suspiciously starts to remind scheduling, which NP-full. Was specific here to check laziness, but, , this hobby  - to palm off the disguised NP-full task and with innocent eyes to ask to find the optimal decision for polynominal time. The task obviously linear...

18

Re: a from company ABBYY

Hello, Kodt, you wrote: the Help 2: Why not 1?

19

Re: a from company ABBYY

Hello, Erop, you wrote: E> Hello, Kodt, you wrote:>> the Help 2: E> Why not 1? . The total going successively el arrays turns out adding new el and subtraction of the oldest.

20

Re: a from company ABBYY

Hello, Erop, you wrote:> the Help 2: E> Why not 1? Really. It is a forum of programmers or whom? It agree that should be 1 and that the list needs to be numbered from zero! Here so: the Help 0:... The Help 1:...

21

Re: a from company ABBYY

22

Re: a from company ABBYY

Hello, Erop, you wrote: E> Hello, bazis1, you wrote: B>> if all numbers nonnegative it is possible. Generally it suspiciously starts to remind scheduling, which NP-full. Was specific here to check laziness, but, , this hobby  - to palm off the disguised NP-full task and with innocent eyes to ask to find the optimal decision for polynominal time. E> the task obviously linear... Linear, if over it to suspect the first sight see floating score with a local maximum which is not always equal global and think "again scheduling?".

23

Re: a from company ABBYY

Hello, Kodt, you wrote: the Amount of passes on an array is a spoiler. The help: I meant which amount? One on count of the left half-sums, one on count of the right? The help 2: no, not the NP-full task. And, well. All right, the good task.

24

Re: a from company ABBYY

Hello, vsb, you wrote: vsb> I understood nothing, it is possible more in detail? What means to take away 5 times on 7? Better the specific code or on an example. Fell out 1 2 3 4 5 4 3, further that will do? And, no, me . The naive variant is bad that will not work.

25

Re: a from company ABBYY

Hello, Iso12, you wrote: L>> the array from whole c Is given. To find such m <= k, that the total a [m] + a [m + 1] +... + a [k] it was maximum. The operating time should be the order of length of an array. I> the knowledge sweep algorithms Here is necessary, it is is specific Kadane's algorithm well is deduced for a pair of clocks in a background mode at desire. I here at first thought that it NP, but then the task sat down at subconsciousness and permanently threw out ideas while I round mountain lake with a backpack climbed. And what if to begin with the largest element? No, a hogwash. And what if to assume, what the element,  included in result is known? Aha, linearly we scan to the left and to the right. And whether it is possible to stop somehow scanning ? It is possible, if the following element reduces the total, and subsequent to it it do not return. And how it simply to define? Scanning from other end and reset at obtaining of the negative total. , the problem is solved. But what great sense to ask it on interview, I do not know. , the only thing that it is possible to reveal in such a way, it that the person before interview spent week for caching in a head of the main algorithms, which else in a week forgets.